Important Questions

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

CBSE CLASS XII

1.b. Name the header file(s) that shall be needed for successful compilation of the following C++ code. 1
void main( )
{ char String[20];
gets(String);
strcat(String,”CBSE”);
puts(String);
}

Ans. stdio.h string.h

1. c. Rewrite the following program after removing the syntactical error(s) if any. Underline each correction. 2
#include<iostream.h>
const int Max 10;
void main()
{ int Numbers[Max];
Numbers = {20,50,10,30,40};
for(Loc=Max-1;Loc>=10;Loc--)
cout>>Numbers[Loc];
}

Ans.
#include<iostream.h>
const int Max=10;//Constant Variable ‘Max’ //must be initialized.Declaration Syntax Error
void main( )
{ int Numbers[Max]={20,50,10,30,40};
for(Loc=Max-1;Loc>=0;Loc--)
cout>>Numbers[Loc];
}

e. Find the output of the following program. 3
#include<iostream.h>
void Withdef(int HisNum=30)
{ for(int I=20;I<=HisNum;I+=5)
cout<<I<<”,”;
cout<<endl;
}
void Control(int &MyNum)
{ MyNum+=10;
Withdef(MyNum);
}
void main()
{ int YourNum=20;
Control(YourNum);
Withdef();
cout<<”Number=”<<YourNum<<endl;
}

Ans: Output:
20,25,30,
20,25,30,
Number=30

f. In the following C++ program what is the expected value of MyMarks from options (i) to (iv)given below. Justify answer.2
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
int Marks[]={99,92,94,96,93,95},MyMarks;
MyMarks = Marks [1+random(2)];
cout<<MyMarks<<endl;
}
(i)99 (ii)94 (iii)96 (iv) None of the above.

Ans. Output: (ii) 94

Paper By Mr. MRK
Email Id : [email protected]@yahoo.com