1.b) Name the header file(s) that shall be needed for successful compilation of the following C++ code.
void main( )
{ char Text[40];
strcpy(Text,”AISSCE”);
puts(Text); }
1
Ans: string.h, stdio.h
1.c) Rewrite the following program after removing the syntactical error(s), if any.Underline each correction.
#include<iostream.h>
const int Size 5;
void main( )
{ int Array[Size];
Array={50,40,30,20,10};
for(Ctr=0;Ctr<Size;Ctr++)
cout>>Array[Ctr];}
2
Ans)
#include<iostream.h>
const int Size=5;
void main( )
{ int Array[Size];
Array={50,40,30,20,10};
for(Ctr=0;Ctr<Size;Ctr++)
cout<<Array[Ctr];
}
1.e) Find the output of the following program.
#include<iostream.h>
void Indirect(int Temp=20)
{ for(int I=10;I<=Temp;I+=5)
cout<<I<<”,”;
cout<<endl;
}
void Direct(int &Num)
{ Num+=10;
Indirect(Num);
}
void main( )
{ int Number=20;
Direct(Number);
Indirect( );
cout<<”Number =”<<Number<<endl;
}
3
Ans: Output:
10,15,20,25,30, 10,15,20, Number =30
f) In the following C++ program what is the expected value of Mysore from options (i) to(iv) given below.Justify your answer.
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
int Score[ ] = {25,20,34,56,72,63},Myscore;
cout<<Myscore<<endl; } Ii) 25 (ii) 34 (iii) 20 (iv) None of the above.
2
Ans: Expected Output:
(i) None of the above.
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )