C++ 2DArray - Two-Dimensional Arrays 1...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Two-Dimensional Arrays
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Write a program to enter elements  in a two dimensional array of 3  rows 2 columns add elements in  each row and store the results in  one dimensional array.
Background image of page 2
3 Void main() {  int arr[3][2]; int results[3]; for(int i=0;i<3;i++) {     int sum=0;       for(int j=0;j<2;j++)       { cin>>arr[i][j]; sum+=arr[i][j];       }    results[i]=sum; } for (int i=0;i<3;i++) cout<<setw(4)<<results[i]<<endl; }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Write a program to create a two-D  array named “table” of 3 rows, 4 columns. Find the largest element in the array  and display it along with the message “the max input in the array is:”
Background image of page 4
5 Void main() { int ar[3][4]; for(int i=0;i<3;i++) for(int j=0;j<4;j++) cin>>ar[i][j]; max=ar[0][0]; for(int i=0;i<3;i++) for(int j=0;j<4;j++) if (ar[i][j]>max)     max=ar[i][j];  cout<<“the max input in the array is: “<<max; }
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 The following table shows the amount bought per month of the listed four products: Exercise 1 2 3 Tea 13 17 50 Sugar 20 14 16 Rice 30 18 50 Coffee 40 30 60 Product Month
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/12/2012 for the course IT 101 taught by Professor Fadi during the Spring '12 term at University of Damascus.

Page1 / 15

C++ 2DArray - Two-Dimensional Arrays 1...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online