Lab02

=CS215 Summer 2=

__ Goals and Objectives __
For this lab, you will develop and modify a simple “Hello, World!” program that will demonstrate the basic structure of a C++ program. After the completion of this lab, you should be able to write a simple C++ program that displays output on the console and accepts input from the keyboard. You should also be able to declare variables to hold characters, integers and real numbers.

Key in the following program, compile and execute:

using namespace std; int main(argc, char argv) { cout << "Hello, World!" << endl; return 0; }
 * 1) include

Modify the program so that “Hello,our name” is displayed on the console after “Hello, World!”.
 * Exercise 1:**

Just as there is a “cout” object that represents the standard output device (console), there is a “cin” object that represents the standard input device (keyboard). As you have seen, the stream operator “<<” send data from variables to the “cout” object. Likewise, there is a “>>” operator is used to stream data from the “cin” object to a variable. cin >> variable;
 * Exercise 2:**

Modify your program to ask for and accept an integer value from the keyboard. Then display the result of multiplying the entered integer by two. Your output should look like this:

Hello, World! Hello, Please enter an integer value: 5 That number is exactly half of 10

Modify your program to divide the number that was input by three and display the result. Your output should look like:
 * Exercise 3:**

Hello, World! >Hello, Please enter an integer value: 5 That number is exactly half of 10 That number divided by three is 1.66667


 * Exercise 4:**

You have now written a program that will accept numeric input from the keyboard, convert data from one type to another and display output on the console. Next, we will accept data from the keyboard, convert it from numeric to character or character to numeric and display the result on the console. Your output should look like:

Hello, World! Hello, Please enter an integer value: 5 That number is exactly half of 10 Enter a letter of the alphabet: a The ASCII value of that letter is 97 Enter a number from 65 to 90: 65 That number is the ASCII code for the letter A


 * Exercise 5:**

Put your program in a .zip file and send it to my email.