COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT C++ CODES PART#05 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT USING FOR LOOP #include<constream.h> void main() {clrscr(); int a,b,c ; for(a=1;a<=10;a++){ cout<<"\n"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. for(b=1;b<=10;b++){ c=a*b; cout<< c << ""; } getch();} } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print * 15 times with two loops #include<constream.h> void main() {clrscr(); int a,b; for(a=1;a<=5;a++){ for(b=1;b<=a;b++){ cout<<"*"; cout<<endl;} getch();}} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print * as shown in the output #include<constream.h> void main() {clrscr(); int a,b,c; for(a=1;a<=5;a++){ for(c=5;c>=a;c--){ cout<<"" ;} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. for(b=1;b<=a;b++){ cout<<"*";} cout<<endl;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print * as shown in the output #include<constream.h> void main() {clrscr(); int a,b,c; for(a=1;a<=7;a+=2){ for(c=5;c>=a;c-=2){ cout<<"";} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE… for(b=1;b<=a;b++){ cout<<"*";} cout<<endl;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print table of any number #include<constream.h> void main() {clrscr(); int a,b,c; cin>>a; for(b=1;b<11;b++){ c=a*b; cout<<endl<<a<<"*"<<b<<"="<<c;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print * as shown in the output #include<constream.h> void main() {clrscr(); int a,b; for(a=5;a>=1;a--){ for(b=1;b<=a;b++){ cout<<"*";} cout<<endl;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT output COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print * as shown in the output… #include<constream.h> void main() {clrscr(); int a,b,c,d,e ; for(a=1;a<=7;a+=2){ for(c=5;c>=a;c-=2){ cout<<" " ;} for(b=1;b<=a;b++){ COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. cout<<"*";} cout<<endl;} for(d=5;d>=1;d-=2){ for(e=5;e>=d;e-=2){ cout<<" ";} for(b=1;b<=d;b++){ getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print 7 as shown in output.. #include<constream.h> void main() {clrscr(); int a,b; for(a=1;a<=5;a++){ for(b=1;b<=a;b++){ cout<<"7";} cout<<endl;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Print only result of tables from 1 to 5 #include <constream.h> void main() { clrscr(); for(int i=1;i<=10;i++) for(int j=1;j<=5;j++) COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE… { cout << i*j << "\t"; } cout << endl; getch(); NOTE:THIS PROGRAM IS PROPERLY INDENTED COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONCLUSION NICE WORDINGS…. Without continual growth and progress, such words as improvement, achievement, and success have no meaning. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT