Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Similar presentations


Presentation on theme: "ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT"— Presentation transcript:

1 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
C++ CODES PART#11 ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

2 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
SIMPLE ARRAY PROGRAM #include<constream.h> void main() {clrscr(); int age[4]; for(int j=0;j<4;j++) { ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

3 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue…. cout<<"enter an age:"; cin>>age[j]; } for(j=0;j<4;j++) cout<<"you entered"<<age[j]<<endl; getch(); ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

4 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
OUTPUT….. ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

5 Averaging array elements
#include<constream.h> void main() {clrscr(); const int size=6; double sales [size]; cout<<"enter sales for 6 days\n"; for(int j=0;j<size;j++) ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

6 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue… cin>>sales[j]; double total=0; for(j=0;j<size;j++) total+=sales[j]; double average=total/size; cout<<"average="<<average<<endl; getch();} ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

7 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…. ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

8 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Initialize an array #include<constream.h> void main() { clrscr(); float a[7]={4.5,1.4,7.5,9.5,6.5,3.6,7.8}; for(int i=0;i<7;i++) cout<<"a["<<i<<"]="<<a[i]<<","; getch();} ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

9 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output… ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

10 Multidimensional array
#include <constream.h> const int SIZE1=3; const int SIZE2=5; void main() { clrscr(); ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

11 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue…. int a[SIZE1][SIZE2]; cout << "Enter 15 integer, 5 per row: "<< endl; for (int i=0; i<3; i++) { cout << "Row " << i+1 << ":" << endl; for (int j=0; j < 5; j++) ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

12 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue… cin >> a[i][j]; } // end for(i) for (i = 0; i < 3 ; i++) { for (int j=0; j<5 ; j ++) ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

13 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Continue… cout << a[i][j] << " "; cout << endl; }// end main6 getch(); } ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

14 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Output…. ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

15 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
NICE WORDINGS… Tabeyat ki Narmi aur Sakhawat, insan ko Dushmnon k dilon main b Mehboob bana deti hai….. AY ALLAH PAK, jab maine tujh se nahi manga tab bhi tu ne mujhe ataa kiya ... tou ye kaise mumkin hai k main tujh se mangon or tu ataa na kare…… ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT


Download ppt "ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT"

Similar presentations


Ads by Google