CBSE computer and communication technology
Sponsor Area
Write the type of C++ tokens (keywords and user defined identifiers) from the following:
(i) new
(ii) While
(iii) case
(iv) Num_2
Types of C++ tokens:
(i) new - Keyword
(ii) While - User defined Identifier
(iii) case - Keyword
(iv) Num_2 - User defined Identifier
Sponsor Area
Anil typed the following C++ code and during compilation, he found three errors as follows:
(i) Function strlen should have prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
On asking, his teacher told him to include necessary header files in the code.Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following code.
{
char Txt[] = 'Welcome';
for(int C= 0; C<strlen(Txt); C++)
Txt[C] = Txt[C]+1;
cout<<Txt<<endl;
}
Header files require for successful compilation and execution of the given code are:
string.h
iostream.h
Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.
void main()
{
cout<<'Enter an Alphabet:';
cin>>CH;
switch(CH)
case 'A' cout<<'Ant'; Break;
case 'B' cout<<'Bear' ; Break;
}
void main()
{
cout<<'Enter an Alphabet:';
char CH;
cin>>CH;
switch(CH)
{
case ‘A’ :
cout<<'Ant'; break;
case ‘B’ :
cout<<'Bear'; break;
}
}
Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.
#define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
void main()
{
int A,B,NUM[] = {10,23,14,54,32};
for(int CNT =4; CNT>0; CNT--)
{
A=NUM[CNT];
B=NUM[CNT-1];
cout<<Diff(A,B)<<'#';
}
}
Output: 22#40#9#13#
Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
void main()
{
int *Point, Score[]={100,95,150,75,65,120};
Point = Score;
for(int L = 0; L<6; L++)
{
if((*Point)%10==0)
*Point /= 2;
else
*Point -= 2;
if((*Point)%5==0)
*Point /= 5;
Point++;
}
for(int L = 5; L>=0; L--){
cout<<Score[L]<<'*';
}
}
Output: 12*63*73*15*93*10*
Sponsor Area
Mock Test Series
Mock Test Series



