COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT C++ CODES PART#11 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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++) { COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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(); COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT….. COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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++) COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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();} COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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();} COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output… COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Multidimensional array #include <constream.h> const int SIZE1=3; const int SIZE2=5; void main() { clrscr(); COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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++) COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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 ++) COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue… cout << a[i][j] << " "; cout << endl; }// end main6 getch(); } COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
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…… COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT