Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming Lesson 3. #include #include main ( ) { cout << “ Welcome to Virtual University “; }

Similar presentations


Presentation on theme: "Introduction to Programming Lesson 3. #include #include main ( ) { cout << “ Welcome to Virtual University “; }"— Presentation transcript:

1 Introduction to Programming Lesson 3

2 #include #include main ( ) { cout << “ Welcome to Virtual University “; }

3 Variable Variable X

4 Variable Pic of the memory Pic of the memory 25 25 10323 10323 name of the variable

5 Variable Variable starts with 1.Character 2.Underscore _ (Not Recommended)

6 Variable Small post box Small post box X

7 Variable Variable is the name of a location in the memory e.g. x= 2; e.g. x= 2;

8 Variable In a program a variable has: 1. Name 2. Type 3. Size 4. Value

9 Assignment Operator = x = 2 X 2

10 Assignment Operator L.H.S = R.H.S. X+ 3 = y + 4 Wrong Z = x +4 x +4 = Z Wrong

11 X = 10 ; X = 30 ; X 10 X 30

12 X = X + 1; X 10 + 1 = X 11

13 Data type int i ; -> Declaration line int i ; -> Declaration line i

14 #include #include 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 ; }

15 int x, y, z ; int x; int y; int z ;

16 Data Types 1. int 2. short 3. long 4. float 5. double 6. char

17 Arithmetic operators Plus+ Minus- Multiply* Divide/ Modulus%

18 Arithmetic operators i + j x * y a / b a % b

19 % = Remainder 5 % 2 = 1 2 % 2 = 0

20 4 / 2 = 2 5 / 2 = ?

21 Precedence Highest:( ) Highest:( ) Next:*, /, % Next:*, /, % Lowest:+, - Lowest:+, -


Download ppt "Introduction to Programming Lesson 3. #include #include main ( ) { cout << “ Welcome to Virtual University “; }"

Similar presentations


Ads by Google