Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- #define m 3
- #define n 4
- void main()
- {
- int i, j, total=0;
- int x[m][n]={{1,2,3,4},
- {5,6,7,8},
- {9,10,11,12},
- };
- float average;
- clrscr();
- //for loop, row by row
- for(i=0; i<m; i++)
- //for loop, column by column
- for(j=0; j<n; j++)
- {
- cout<<"x["<<i<<"]["<<j<<"]="<<x[i][j]<<endl;
- total=total+x[i][j];
- }
- cout<<"Total of the sequence="<<total<<endl;
- average=(float)total/(float)(m*n);
- cout<<"average="<<total<<"/"<<m*n<<endl;
- cout<<"Average of the sequence="<<average<<endl;
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment