Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ CODES PART#04 1 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT.

Similar presentations


Presentation on theme: "C++ CODES PART#04 1 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT."— Presentation transcript:

1 C++ CODES PART#04 1 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

2 CIN>> AND COUT<< #include void main(){clrscr(); float a,b; cin>>a; cin>>b; cout<<a+b<<endl<<a-b<<endl<< a/b<<endl<<a*b; getch(); } 2 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

3 OUTPUT…… 3 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

4 WELL ORGANIZED FORMAT OF CIN>> AND COUT<< #include void main(){float a,b; clrscr(); cout<<"plz enter the first no:"; cin>>a; cout<<"plz enter the second no:"; cin>>b; 4 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

5 CONTINUE… cout<<endl<<endl<<"the sum of two number is="<<a+b; cout<<endl<<endl<<"the difference of two number is="<<a-b; cout<<endl<<endl<<"the multiplication of two number is="<<a*b; cout<<endl<<endl<<"the division of two number is="<<a/b; getch(); } 5 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

6 OUTPUT… 6 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

7 MULTIPLICATION OF TWO NUMBERS #include void main() {clrscr(); int a; float b; double c; 7 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

8 CONTINUE… a=4; b=7; c=a*b; cout<<"\n c="<<c; getch(); } 8 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

9 OUTPUT….. 9 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

10 WHITE SPACE #include void main () { clrscr (); 10 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

11 CONTINUE… cout<< " civil\n" ; getch ();} OUTPUT…. civil 11 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

12 print character from the decimal value of ASCII TABLE #include void main() { clrscr(); cout<<char(65); getch();} Output A 12 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

13 Print integer for given character from ASCII TABLE #include void main() {clrscr(); cout<<int('a'); getch();} 13 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

14 Output….. 14 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

15 Relational operator example #include void main() {clrscr(); int a; cout<<"a<10 is "<<(a<10)<<endl; cout 10 is " 10)<<endl; cout<<"a==10 is "<<(a==10)<<endl; getch(); } 15 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

16 Output… 16 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

17 Using for loop generate series from 1 to 10 #include void main() {clrscr(); int a; for(a=1;a<11;a++) { cout<<a<<endl;} getch();} 17 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

18 Output…. 18 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

19 Display cubes from series 1 to 10 #include void main() {clrscr(); int a; for(a=1;a<=10;a=a+1) 19 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

20 Continue…. { cout<<setw(4)<<a; int cube=a*a*a; cout<<setw(6)<<cube<<endl;} getch();} 20 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

21 OUTPUT….. 21 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

22 Factorial program #include void main() { clrscr(); unsigned int a; unsigned long fact=1; cout<<"input number:"; 22 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

23 CONTINUE….. cin>>a; for(int b=a;b>0;b--) { fact*=b; cout<<"factorial is "<<fact<<endl; getch();} } 23 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

24 Output….. 24 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

25 +,-,*,/ using setw #include void main() {clrscr(); float a=2.5,b=3.5; cout<<"\n a+b"<<setw(5)<<"="<<setw(5)<<(a+b)<< endl; 25 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

26 CONTINUE… cout<<"\n a-b"<<setw(5)<<"="<<setw(5)<<(a-b)<<endl; cout<<"\n a*b"<<setw(5)<<"="<<setw(5)<<(a*b)<< endl; cout<<"\n a/b"<<setw(5)<<"="<<setw(5)<<(a/b)<< endl; getch();} 26 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

27 Output…. 27 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

28 Provides ASCII character as well as its integer value… #include void main() {clrscr(); int ch; ch=getche() ; cout<<endl<<ch; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT 28

29 Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT 29

30 epilogue This was all about this lecture Nice wordings: If any anybody has not made any mistake in their life that means, they have never tried a new thing in their life…. 30 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT


Download ppt "C++ CODES PART#04 1 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT."

Similar presentations


Ads by Google