1 / 30

C++ CODES PART#04

C++ CODES PART#04. CIN>> AND COUT<<. #include< constream.h > void main(){ clrscr (); float a,b ; cin >>a; cin >>b; cout << a+b << endl <<a-b<< endl << a/b<< endl <<a*b; getch (); }. OUTPUT……. WELL ORGANIZED FORMAT OF CIN>> AND COUT<<. #include< constream.h > void main(){float a,b ;

leora
Download Presentation

C++ CODES PART#04

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  19. Display cubes from series 1 to 10 #include<constream.h> #include<iomanip.h> void main() {clrscr(); int a; for(a=1;a<=10;a=a+1) 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();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  22. Factorial program #include<constream.h> void main() { clrscr(); unsigned int a; unsigned long fact=1; cout<<"input number:"; 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();} } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

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

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

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

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

  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…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

More Related