Saturday 17th April 2021
REGISTRATION
Online Fashion Store

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

DELHI 2008:

3.a) Write a function in C++, which accepts an integer array and its size as arameters and rearranges the array in reverse.

Example:

If an array of nine elements initially contains the elements as 4, 2, 5, 1, 6, 7, 8, 12, 10. Then the function should rearrange the array as 10,12, 8, 7, 6, 1, 5, 2, 4

Solution:

void receive(int A[ ], int size)
{ int temp;
for(i=0,j=size-1;i<size/2;i++,j--)
{ temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}//end of receive function.

3.b) An array Arr[40][10] is store in the memory along the column with each element occupying 4 bytes. Find out the base address of the location Arr[3][6] if the location Arr[30] [10] is stored at the address 9000.

Solution: Children, Try this answer as an assignment.

3.d) Write a function in C++ to print the product of each column of a two dimensional array passed as the arguments of the function.


Example :

If the two dimensional array contains Then the output should appear as:

Product of Column 1 = 24
Product of Column 2 = 30
Product of Column 3 =240

void receive(int A[ ][ ],int r,int c)
{ int i,j,B[c];
for(i=0;i<c;i++)
B[i]=1;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
B[j]=B[j]*A[i][j];
for(i=0;i<c;i++)
cout<<”\nProduct of Column “<<i+1<<” = “<<B[i];
}

 

Previous Index Next

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