CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran
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
Q.1. c. Rewrite the following program after
removing the syntactical error(s) if any.
Underline each correction.
#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.
#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
Paper By Mr. Ravi Kiran
Email Id : [email protected] |