160 likes | 274 Views
Islamic University of Gaza Faculty of Engineering. Computer Programming. Lab 1 Programming Basics. By Eng . Ruba A. Salamah. Lab Objectives. Basic Input/Output Operations Variables and Data types Arithmetic Operations Constants and Comments. Basic Input/Output Operations.
E N D
Islamic University of Gaza Faculty of Engineering Computer Programming Lab 1 Programming Basics By Eng. Ruba A. Salamah
Lab Objectives • Basic Input/Output Operations • Variables and Data types • Arithmetic Operations • Constants and Comments
Basic Input/Output Operations • We use the command cout<<”String” to display a message on the console for example: cout<<"hello world"; • We use the endlto start a new line for next time cout<<"hello"<<endl; • We can use \n to get same effect: cout<<"hello \n";
Basic Input/Output Operations • The operator << is used to concatenate data for output, for example to display the value of x and y each in a new line : int x=5; int y=6; cout<<"The Value of x is "<< x << endl <<"and the value of y is "<<y<<endl;
Basic Input/Output Operations • On the other hand, to get input from user use the cin>>x command to receive input from user: int x; cout<<”Please enter the value of x”<<endl; cin>>x; • As you notice the user should be prompted to enter an input User Prompt
Lab work #1 • Write a program to display the following output using a single cout statement.
END OF THE LAB Good Luck