1 / 27

C++ CODES PART#03

C++ CODES PART#03. SETW AND IOMANIP.H. # include < constream.h > # include< iomanip.h > void main() { clrscr (); long pop1=2425785, pop2=47, pop3=9761; cout << setw (9)<<"LOCATION"<< setw (12)<<"POPULATION"<< endl. CONTINUE…. << setw (9)<<"Hyderabad"<< setw (12)<<pop1<< endl

hisoki
Télécharger la présentation

C++ CODES PART#03

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

  2. SETW AND IOMANIP.H # include <constream.h> # include<iomanip.h> void main() { clrscr(); long pop1=2425785, pop2=47, pop3=9761; cout<<setw(9)<<"LOCATION"<<setw(12)<<"POPULATION"<<endl COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  3. CONTINUE… <<setw(9)<<"Hyderabad"<<setw(12)<<pop1<<endl <<setw(9)<<"Karachi"<<setw(12)<<pop2<<endl<<setw(9)<<"Lahore"<<setw(12)<<pop3<<endl; cout<<"\a"; getche(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  5. SETW #include<iostream.h> #include<conio.h> #include<iomanip.h> void main() { clrscr(); cout<<setw(40)<<"ENGR.SABA MUGHAL"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  6. CONTINUE… cout<<setw(10)<<"ITC"<<endl; cout<<setw(10)<<123; getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  8. QUADRATIC EQUATION IN PROGRAM #include<constream.h> #include<math.h> #define sqrt void main(void) { clrscr(); float a,b,c,x1,x2; cout<<"Enter values for a, b& c " ; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  9. CONTINUE…. cin>>a>>b>>c; x1=(-b+sqrt(b*b-4*a*c))/(2*a); x1=(-b-sqrt(b*b-4*a*c))/(2*a); cout<<"The roots of Qudratic Equation are "<<x1; cout<<"\n And\t"<<x2; getche(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  11. ENDL AND ADDING NUMBERS #include<iostream.h> #include<conio.h> void main() { clrscr(); int a=10; int b=a+20; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  12. CONTINUE…. float d=3.24; intans=b+d; cout<<a<<endl<<b<<endl<<ans; getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  13. OUTPUT….. 10 30 33 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  14. USING \t # include<constream.h> void main() { clrscr(); int a=1234; int b=56; cout<<"\n"<<a<<"\t"<<b; getche(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  16. IF AND ELSE STATEMENT #include <iostream.h> #include <conio.h> void main() { clrscr(); int agep1,agep2; cout<<"Input Age of first person"; cin>>agep1; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  17. CONTINUE…. cout<<"Input Age of 2nd person"; cin>>agep2; clrscr(); if(agep1>agep2) { cout<<"First Person in Elder "; cout<<(agep1-agep2)<<" Years"; } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  18. CONTINUE…. else { cout<<"2nd Person is Elder"; cout<<(agep2-agep1)<<" Years"; } getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  20. FIBONACCI SERIES #include<iostream.h> #include<conio.h> void main() { clrscr(); int a=1,b=1,ans=0; cout<<a<<" "<<b<<" "; for (inti=1;i<=10;i++) COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  21. CONTINUE…. { //int a=1,ans=0; //cout<<a<<" "; ans=a+b; cout<<ans<<" "; a=b; b=ans; } getche(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  23. IF/ELSE STATEMENT #include<iostream.h> #include<conio.h> void main() { clrscr(); int m1,m2,m3,m4,m5; float perc,tot; cin>>m1>>m2>>m3>>m4>>m5; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  24. CONTINUE…. tot=m1+m2+m3+m4+m5; perc=tot/550*100; if (perc>=90 && perc<=100) { cout<<"A1 Grade";cout<<'\t'<<perc;} else if(perc<90 && perc>=80){ cout<<"A grade";cout<<'\t'<<perc;} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

  25. CONTINUE…. else if(perc<80 && perc>=70){ cout<<"B grade";cout<<'\t'<<perc;} else { cout<<"Improve";cout<<'\t'<<perc;} getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

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

  27. Nice wordings COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

More Related