Download presentation
Presentation is loading. Please wait.
Published byYenny Tan Modified over 5 years ago
1
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
C++ CODES PART#05 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
2
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
3
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. for(b=1;b<=10;b++){ c=a*b; cout<< c << ""; } getch();} } 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
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
6
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output….. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
7
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
8
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE…. for(b=1;b<=a;b++){ cout<<"*";} cout<<endl;} getch();} COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
9
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
10
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
11
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE… for(b=1;b<=a;b++){ cout<<"*";} cout<<endl;} getch();} COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
12
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
13
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
14
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output… COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
15
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
16
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
output COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
17
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
18
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 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
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
21
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output… COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
22
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
23
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CONTINUE… { cout << i*j << "\t"; } cout << endl; getch(); NOTE:THIS PROGRAM IS PROPERLY INDENTED COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
24
COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…. COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
25
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 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.