CBSE Computer Science - Revision Tour(Solved)

CBSE Guess > eBooks > Class XII > CBSE Computer Science Arrays Solved Revision Tour By Mr. Ravi Kiran

COMPUTER SCIENCE ARRAYS

Previous Index Next

3.b) An array T[15][10] is stored in the memory with each element requiring 2 bytes of storage. If the base address of T is 2000, determine the location of T[7][8] when the array VAL is stored (i) Row major (ii) Column major.

Solution: Children, Try this as an assignment.

3.c) Write a user-defined function in C++ to find and display the sum of diagonal elements from a 2D array R[7][7] containing integers.

void displaysum( )
{ int i,j,D1=0,D2=0,R[7][7];
cout<<”\nEnter any 49 values….”;
for(i=0;i<7;i++)
for(j=0;j<7;j++)
{ cin>>R[i][j];
if(i= = j)
D1=D1+R[i][j];
else if ((i+j)= =(size-1))
D2=D2+R[i][j];
}
cout<<”\nThe sum of the elements of the Main Diagonal = “<<D1;
cout<<”\nThe sum of the elements of the Other Diagonal = “<<D2;
}

” If WEALTH is lost, nothing is lost.
If HEALTH is lost, something is lost.
If CHARACTER is lost, everything is lost.”
“The fear of the Lord is the
     beginning of wisdom”

 

Previous Index Next

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )