300 likes | 387 Views
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 ;
E N D
C++ CODES PART#04 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
OUTPUT…… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
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
OUTPUT… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
CONTINUE… a=4; b=7; c=a*b; cout<<"\n c="<<c; getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
WHITE SPACE #include<constream.h> void main () { clrscr (); COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE… cout<< " civil\n" ; getch ();} OUTPUT…. civil COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
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
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
Output… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
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
OUTPUT….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
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
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
+,-,*,/ 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
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
Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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