# CS201-03 - Introduction to Programming Lesson...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Programming Lesson 3 #include <iostream.h> main ( ) { cout << “ Welcome to Virtual University “; } Variable Variable X Pic of the memory 25 Variable 10323 name of the variable Variable starts with Variable 1. Character 2. Underscore _ (Not Recommended) Small post box Variable X Variable Variable is the name of a location in the memory e.g. x= 2; Variable In a program a variable has: 1. Name 2. Type 3. Size 4. Value Assignment Operator = x = 2 X 2 L.H.S = R.H.S. Assignment Operator X+ 3 = y + 4 Wrong Z = x +4 x +4 = Z Wrong X = 10 ; X = 30 ; X X 10 30 X = X + 1; X 10 +1 = 11 X Data type int i ; ­> Declaration line i #include <iostream.h> main ( ) { int x ; int y ; int z ; x = 10 ; y = 20 ; z = x + y ; cout << " x = " ; cout << x ; cout << " y = " ; cout << y ; cout << " z =x + y = " ; cout << z ; } int x, y, z ; int x; int y; int z ; Data Types 1. 2. 3. 4. 5. 6. int short long float double char Arithmetic operators Plus Minus Multiply Divide + ­ * / Modulus % Arithmetic operators i + j x * y a / b a % b % = Remainder 5 % 2 = 1 2 % 2 = 0 4 / 2 = 2 5 / 2 = ? Precedence Highest: Next: Lowest: ( ) * , / , % + , ­ ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online