Download presentation
Presentation is loading. Please wait.
Published byVera Muljana Modified over 6 years ago
1
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
C++ CODES PART#03 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
2
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
SETW AND IOMANIP.H # include <constream.h> # include<iomanip.h> void main() { clrscr(); long pop1= , pop2=47, pop3=9761; cout<<setw(9)<<"LOCATION"<<setw(12)<<"POPULATION"<<endl COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
3
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
4
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT…. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
5
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
SETW #include<iostream.h> #include<conio.h> #include<iomanip.h> void main() { clrscr(); cout<<setw(40)<<"ENGR.SABA MUGHAL"; COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
6
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE… cout<<setw(10)<<"ITC"<<endl; cout<<setw(10)<<123; getch(); } COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
7
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT….. COPY 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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
9
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
10
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT…. COPY 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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
12
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. float d=3.24; int ans=b+d; cout<<a<<endl<<b<<endl<<ans; getch(); } COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
13
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT….. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
14
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
USING \t # include<constream.h> void main() { clrscr(); int a=1234; int b=56; cout<<"\n"<<a<<"\t"<<b; getche(); } COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
15
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…………….. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
16
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
17
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. cout<<"Input Age of 2nd person"; cin>>agep2; clrscr(); if(agep1>agep2) { cout<<"First Person in Elder "; cout<<(agep1-agep2)<<" Years"; } COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
18
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. else { cout<<"2nd Person is Elder"; cout<<(agep2-agep1)<<" Years"; } getch(); COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
19
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT…. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
20
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
FIBONACCI SERIES #include<iostream.h> #include<conio.h> void main() { clrscr(); int a=1,b=1,ans=0; cout<<a<<" "<<b<<" "; for (int i=1;i<=10;i++) COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
21
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. { //int a=1,ans=0; //cout<<a<<" "; ans=a+b; cout<<ans<<" "; a=b; b=ans; } getche(); } COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
22
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT… COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
23
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
24
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
25
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. else if(perc<80 && perc>=70){ cout<<"B grade";cout<<'\t'<<perc;} else { cout<<"Improve";cout<<'\t'<<perc;} getch(); } COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
26
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT…. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
27
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Nice wordings COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.