350 likes | 446 Views
C++ CODES PART#06. Calculate area of a circle using a=pi*r*r. #include<iostream.h> #include<conio.h> void main() { clrscr(); float rad; const float pi=3.14159f; cout<<"Enter Radious :";. CONTINUE…. cin>>rad; float area=pi*rad*rad; cout<<"Area is :"<<area<<endl; getch(); }.
E N D
C++ CODES PART#06 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Calculate area of a circle using a=pi*r*r #include<iostream.h> #include<conio.h> void main() { clrscr(); float rad; const float pi=3.14159f; cout<<"Enter Radious :"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE… cin>>rad; float area=pi*rad*rad; cout<<"Area is :"<<area<<endl; getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Do While loop #include<constream.h> void main() { clrscr(); int a; a=1; do COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. { cout<<a<<endl;a++; } while (a<11); getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Using power function #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter the limit upto where you want the series"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue…. cin>>a; for(b=1;b<=a;b++) {c=pow(b,2); cout<<c<<" ";} cout<<"this series is the required one"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Generate series as shown in the output… #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter limit"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue… cin>>a; for(b=1;b<=a;b++) {c=2*b*pow(-1,b); cout<<c<<" ";} cout<<"this series is the required one"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Generate series as shown in the output… #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter the last limit"; cin>>a; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue…. for(b=1;b<=a;b++){ c=2*b*pow(-1,b+1); cout<<c<<" ";} cout<<"hence this is the required series"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Generate series as shown in the output… #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter the last limit"; cin>>a; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue….. for(b=0;b<=a;b++) {c=pow(3,b); cout<<c<<" ";} cout<<"this series is the required one"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
While loop #include<constream.h> void main() {clrscr(); int n; while(n!=0) cin>>n; cout<<endl; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. • User enters many numbers when he/she enters zero so program terminates COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Generate series as shown in output using while loop #include<constream.h> #include<math.h> void main() { clrscr(); int a,b,r; cout<<"plz enter your limit"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue…. cin>>b; a=1; while(a<=b) {r=2*a*pow(-1,a+1); cout<<r<<" "; a++;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Generate series as shown in output using while loop #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,r; cout<<"enter limit"; cin>>b; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue…. a=0; while(a<b) {r=pow(3,a); cout<<r<<" "; a++;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Generate series as shown in output using while loop #include<constream.h> #include<math.h> void main() { clrscr(); int a,b,r; cout<<"enter the limit"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue… cin>>b; a=1; while (a<=b) {r=pow(a,2); cout<<r<<" "; a++;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Do-while loop #include<constream.h> void main() {clrscr(); long dividend,divisor; char ch; do { COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue… cout<<"enter dividend:"; cin>>dividend; cout<<"enter divisor:"; cin>>divisor; cout<<"quotient is "<<dividend/divisor; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue…. cout<< " , remainder is "<<dividend%divisor; cout<<" \n do another?(y/n):"; cin>>ch;} while (ch!='n'); getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONCLUSION • NICE WORDINGS…. • It is more difficult to stay on top than to get there. The secret of success is that we never, never give up • Barish ka Qatra Seepi or Sanp dono kay Munah mein girta hai Jab keh Sanp ussay Zehar bana deta hai aur Seep Usay Moti. Jis ka jaisa "Zarf" waisi Uss ki "Takhleeq". COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT