introduction to programming lesson 3. #include #include main ( ) { cout
DESCRIPTION
Variable Variable XTRANSCRIPT
![Page 1: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/1.jpg)
Introduction to Introduction to ProgrammingProgramming
Lesson 3Lesson 3
![Page 2: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/2.jpg)
#include <iostream.h>#include <iostream.h>main ( )main ( ){{
cout << “ Welcome to Virtual University cout << “ Welcome to Virtual University “;“;
}}
![Page 3: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/3.jpg)
VariableVariable
VariableVariable X
![Page 4: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/4.jpg)
VariableVariable Pic of the memoryPic of the memory
2525
1032310323
namenameof the of the variablvariablee
![Page 5: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/5.jpg)
VariableVariableVariable starts withVariable starts with
1.1. CharacterCharacter2.2. Underscore _ Underscore _ (Not (Not
Recommended)Recommended)
![Page 6: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/6.jpg)
VariableVariable Small post boxSmall post box
X
![Page 7: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/7.jpg)
VariableVariableVariable is the name of a Variable is the name of a
location inlocation inthe memorythe memory
e.g. x= 2;e.g. x= 2;
![Page 8: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/8.jpg)
VariableVariableIn a program a variable In a program a variable
has:has:1.1. NameName2.2. TypeType3.3. SizeSize4.4. ValueValue
![Page 9: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/9.jpg)
Assignment Assignment OperatorOperator
==x = 2x = 2
X 2
![Page 10: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/10.jpg)
Assignment Assignment Operator Operator
L.H.S = R.H.S.L.H.S = R.H.S.
X+ 3 = y + 4 X+ 3 = y + 4 WrongWrongZ = x +4Z = x +4x +4 = Z x +4 = Z WrongWrong
![Page 11: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/11.jpg)
X = 10 ; X = 10 ;
X = 30 ;X = 30 ;
X 10
X 30
![Page 12: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/12.jpg)
X = X + 1;X = X + 1;X 10 + 1
= X
11
![Page 13: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/13.jpg)
Data typeData type int i ; -> int i ; ->
Declaration lineDeclaration line
ii
![Page 14: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/14.jpg)
#include <iostream.h>#include <iostream.h>main ( )main ( ){{
int x ;int x ;int y ;int y ;int z ;int z ;x = 10 ;x = 10 ;y = 20 ;y = 20 ;z = x + y ;z = x + y ;
cout << " x = " ;cout << " x = " ;cout << x ;cout << x ;
cout << " y = " ;cout << " y = " ;cout << y ;cout << y ;
cout << " z =x + y = " ;cout << " z =x + y = " ;cout << z ;cout << z ;
}}
![Page 15: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/15.jpg)
int x, y, z ;int x, y, z ;int x; int y; int z int x; int y; int z
;;
![Page 16: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/16.jpg)
Data TypesData Types1.1. intint2.2. shortshort3.3. longlong4.4. floatfloat5.5. doubledouble6.6. charchar
![Page 17: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/17.jpg)
Arithmetic Arithmetic operatorsoperators
PlusPlus ++MinusMinus --MultiplyMultiply **
DivideDivide / / ModulusModulus %%
![Page 18: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/18.jpg)
Arithmetic Arithmetic operatorsoperators
i + ji + jx * yx * ya / ba / ba % ba % b
![Page 19: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/19.jpg)
% = Remainder% = Remainder
5 % 2 = 15 % 2 = 12 % 2 = 02 % 2 = 0
![Page 20: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/20.jpg)
4 / 2 = 24 / 2 = 25 / 2 = ?5 / 2 = ?
![Page 21: Introduction to Programming Lesson 3. #include #include main ( ) { cout](https://reader036.vdocuments.us/reader036/viewer/2022062505/5a4d1bf37f8b9ab0599e7018/html5/thumbnails/21.jpg)
PrecedencePrecedence Highest:Highest: ( )( ) Next:Next: * , / , %* , / , % Lowest:Lowest: + , -+ , -