Page 272 - C++
P. 272
SECTION A
[Only for candidates, who opted for C++]
1. (a) Write the type of C++ tokens (keywords and user defined identifiers)
from the following : 2
(i) new
(ii) While
(iii) case
(iv) Num_2
(b) 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 : 1
void main()
{
char Txt[] = "Welcome";
for(int C= 0; C<strlen(Txt); C++)
Txt[C] = Txt[C]+1;
cout<<Txt<<endl;
}
(c) Rewrite the following C++ code after removing any/all syntactical
errors with each correction underlined. 2
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;
}
91 2