COMPUTER SCIENCE ARRAYS

3.b) An array Arr[35][15] is stored in the memory along the row with each of its element occupying 4 bytes . Find out the Base address and the address of element Arr[20][5] , if the location Arr[2][2] is stored at the address 3000.

Solution: Children, Try this answer as an assignment.

3.d) Write a function in C++ to print sum of all values which either are divisible by 3 or divisible by 5 present in a 2D array passed as the argument of the function.

Ans:-

void Sum(int A[ ][ ],int R,int C)
{ int S=0,i,j;
for(i=0;i<R;i++)
for(j=0;j<C;j++)
if((a[i][j]%3= =0)||(a[i][j]%5= =0))
S=S+A[i][j];
cout<<" nThe Sum of all the values which
are divisible by 3 or 5 in the array = “<<S;
}

DELHI 2004:

3.a) Define the function SwapArray(int[ ],int),that would expect a 1D integer array NUMBERS and its size N. the function should rearrange the array in such a way that the values of that locations of the array are exchanged. (Assume the size of the array to be even).

Example :
If the array initially contains {2, 5, 9, 14, 17, 8, 19, 16}. Then after rearrangement the array should contain {5, 2, 14, 9, 8, 17, 16, 19}.

Solution:

void SwapArray(int NUMBERS[ ], int N)
{ int i,j,temp;
/* cout<<”\nThe elements before
doing the desired alterations…”;
for(i=0;i<N;i++)
cout<<NUMBERS[i]<<’\t’;
*/
for(i=0;i<N-1;i+=2)
{ temp=NUMBERS[i];
NUMBERS[i]=NUMBERS[i+1];
NUMBERS[i+1]=temp;
}
/* cout<<”\nThe elements after completed the desired alterations…”;
for(i=0;i<N;i++)
cout<<NUMBERS[i]<<’\t’; */
}

3.b) An array ARR[5][5] is stored in the memory with each element occupying 3 bytes of space. Assuming the base address of ARR to be 1500, compute the address of ARR[2][4],when the array is stored :

Solution: Children, Try this answer as an assignment.

 

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/array7.php on line 121

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/array7.php on line 121

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

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/array7.php on line 123