Thursday 02nd May 2024
REGISTRATION
Online Fashion Store

Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran

CBSE CLASS XII

Q. 2. An array Arr[50][10] is store in the memory along the row with each element occupying. bytes. Find out the Base address of the location Arr[20][50], if the location Arr[10][25] is stored at the address 10000.

Solution:

Children, Try this answer as an assignment.

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

Example:

if the two imensional array contains
Then the output should appear as:
Product of Row 1 = 8000
Product of Row 2 = 6000
Product of Row 3 =3600
Product of Row 4 = 2400
void receive(int A[ ][ ],int r,int c)
{ int i,j,B[r];
for(i=0;i<r;i++)
B[i]=1;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
B[i]=B[i]*A[i][j];
for(i=0;i<r;i++)
cout<<”\nProduct of Row “<<i+1<<” = “<<B[i];
}

DELHI 2007

Q. 1. Write function in C++ which accepts an integer array and size as arguments and replaces elements having odd values with thrice its value and elements having even values with twice its value.

Example :

if an array of five elements initially contains elements as 3, 4, 5, 16, 9
The the function should rearrange the content of the array as 9, 8, 75, 32, 27

Solution:

void manipulate (int a[ ],int size)
{ for (i=0;i<size;i++)
{ if (a[i]%2= =1)
a[i]=a[i]*3;
else
a[i]=a[i]*2;
cout<<a[i]<<’,’;
}
}

Q. 2. An array Array[20][15] is stored in the memory along the column with each element occupying 8 bytes. Find out the base address of the element Array[2][3] if the element Array[4] [5] is stored at the address 1000.

Solution:

Given Data: Aray [20][15] W=8 B=? R=20 C=15 Lr = 0 Lc = 0
Address of Array [2][3] =?
Address of Array[4][5] =1000.
Address of an element (I,J) in column major =B + W ( (I-Lr) + R(J-Lc ) )
Therefore 1000=B+8*((4-0)+20(5-0))
1000=B+8*(4+20*5)
1000 =B+8*104
1000=B+832
B =1000-832
B =168
Therefore Address of Array[2][3]=168+8*((2-0)+20(3-0))
=168+8*(2+20*3)
=168+8*62
=168+496
=664

Paper By Mr. Ravi Kiran
Email Id : [email protected]