Monday, September 19, 2011

Object Oriented Programming 2nd Class

Object Oriented Programming 2nd  Class
 CSE222: Object Oriented Programming  Lab 1

 

Lab Objectives
To gain experience with
      the activity of programming
      programming with cout object
      using your compiler
      recognizing syntax  errors

1. The first exercise is to make sure you can type in, compile, link, and run a simple C++ program on your own C++ programming system, whatever that may be.
Type in the following program and run it.
#include <iostream.h>
int main (void)
{
cout << "G'day mate" << endl;
return (0);
}
This is a simple C++ program that uses iostream for output.

Now using the experience of this program do the following programs exercise:

1.Write a program to print your name, identification number, and date of birth. 1. Write a program that prints the message


My name is Hector, I am
a vector.
I am the subject of many a
physics lecture!

a.  all on one line
b.  on two lines
c.  on eight lines
d.  inside a box drawn with asterisks



2. Find the errors in the following program.

#  include iore.h
mian(}
(
 couts << \n"I like to write/n before I've read it.\n\n;
 cout << "Then, with my pen, I always edit."\n;
 Cout >> "But, with computer\s, now I type;
 cout <<("An never, ever get it right./n")
}

3a. Indicate how many cout statements you would use to print out the following:
PART NO                 PRICE
T1267                       $6.34
T1300                       $8.92
T2401                       $65.40
T4482                      $36.99
b. What is the minimum number of cout statements that could be used to print out the table in 3a.
C. Write a complete C++ program to produce the output illustrated in exercise 3a.

1.5. What would be the output of the following program?

include <iostream.h>
int main()
{
 cout << "The Hound of " << "t" << "h" << "e" << " ";
 cout << "Baskervi" << "l" << "l" << "es\n";
 cout << "by Arthur " << "C" << "onan Doyle\n";
 return 0;
}

No comments:

Post a Comment