COMPUTER SCIENCE ARRAYS

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”

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/array13.php on line 96

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/array13.php on line 96

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/array13.php on line 98

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/array13.php on line 98