Date post: | 18-Jan-2018 |
Category: |
Documents |
Upload: | julianna-wiggins |
View: | 266 times |
Download: | 0 times |
ISLAMIC UNIVERSITY OF GAZA FACULTY OF ENGINEERING
Computer Programming
Lab 1 Programming Basics
By Eng. Ruba A.
Salamah
Lab Objectives 1. Basic Input/Output
Operations 2. Variables and Data types 3. Arithmetic Operations 4. 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 endl to 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.
Variable Types
Lab work # 2
Arithmetic Operators
Arithmetic Operators
Shorthand Assignment Operators:
Lab work #3
Lab work #4
Homework
Homework
END OF THE LAB
Good Luck