Important Questions

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

CBSE CLASS XII

Ans:

Output:
[1]10&15
[2]21&13
[1]11&16
[2]22&14

f. In the following program, find the correct possible output(s) from the options: 2
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
char City[][10]= {“DEL”,”CHN”,”KOL”,”BOM”,”BNG”};
int Fly;
for(int I=0; I<3;I++)
{ Fly=random(2) + 1;
cout<<City[Fly]<<”:”;
}
}

Outputs:

(i) DEL : CHN : KOL:
(i) CHN: KOL : CHN:
(ii) KOL : BOM : BNG:
(iii) KOL : CHN : KOL:

Ans:

Since random(2) gives either 0 or 1, Fly value will be either 1 or 2. (random(n) gives you any number between 0 to n-1) City[1] is “CHN”. City[2] is “KOL”. Since I value from 0 to 2 (ie<3), 3 iterations will takes place. So the possible output consists 3 strings separated by :, each of them may be either
“CHN” or “KOL”.

So the possible output will be
(ii) CHN : KOL : CHN:
(iv) KOL :CHN : KOL:

2008 Outside Delhi

Q.1.b. Name the header files that shall be needed for the following code: 1
void main( )
{ char word[]=”Exam”;
cout<<setw(20)<<word;
}

Ans:

iostream.h, iomanip.h

Q. 1.c. Rewrite the following program after removing the syntax error(s) if any. Underline each correction. 2
#include<iostream.h>
void main( )
{ One=10,Two=20;
Callme(One;Two);
Callme(Two);
}
void Callme(int Arg1,int Arg2)
{ Arg1=Arg1+Arg2;
Count<<Arg1>>Arg2;
}

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