1.a
|
Find the correct identifiers out of the following , which can be used
for naming Variable , Constants or Functions in a C++ program:
For , while , INT ,New ,
delete ,1stName , Add+Subtract , name1
|
2
|
||||||||||||||||||||
Ans
|
For ,INT , New , name1
|
|||||||||||||||||||||
b
|
Observe the following program very carefully and write the name of
those header file(s) , which are
essentially needed to compile and execute the following program successfully:
typedef char STRING[80];
void main()
{
STRING Txt[] = “We love
Peace”;
int Count=0;
while (Txt[Count]!=’\o’)
If(isalpha(Txt[Count]))
Txt[Count++]=’@’;
else
Txt[Count++]=’#’;
puts(Txt);
}
|
1
|
||||||||||||||||||||
Ans
|
ctype , stdio
|
|||||||||||||||||||||
c
|
Observe the following C++ code very carefully and rewrite it after
removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in
the program.
#Define float MaxSpeed=60.5;
void main()
{
int MySpeed
char Alert=’N’;
cin>>MySpeed;
if MySpeed>MaxSpeed
Alert=’Y’;
cout<<Alert<<endline;
}
|
2
|
||||||||||||||||||||
Ans
|
#define
void main()
{
int MySpeed ; //Error 4
char Alert=’N’;
cin>>MySpeed;
if (MySpeed>MaxSpeed) //Error 5
Alert=’Y’;
cout<<Alert<<endl; //Error 6
}
|
|||||||||||||||||||||
d
|
Write the output of the following C++ program code:
Note: Assume all required header files are already being included in
the program.
void Location (int &X,int Y=4)
{
Y+=2;
X+=Y;
}
void main()
{
int PX=10,PY=2;
Location(PY);
cout<<PX<<” ,
“<<PY<<endl;
Location(PX,PY);
cout<<PX<<” ,
“<<PY<<endl;
}
|
2
|
||||||||||||||||||||
Ans
|
10,8
20,8
|
|||||||||||||||||||||
e
|
Study the following program and select the possible output(s) from
the option (i) to (iv) following it. Also, write the maximum and the minimum
values that can be assigned to the variable VAL.
Note:
-Assume all required header files are already being included In the
program.
-random(n) function generates an integer between 0 and n-1.
void main()
{
randomize();
int VAL;
VAL=random(3)+2;
char GUESS[]=”ABCDEFGHIJK”;
for(int I=1;I<=VAL;I++)
{
for(int J=VAL;J++)
cout<<GUESS[J];
cout<<endl;
}
}
|
2
|
||||||||||||||||||||
Ans
|
(ii) and (iii)
Min Value of VAL =2
Max Value of VAL=4
|
Thursday, 25 February 2016
11th & 12th CS 2015(Outside Delhi) Common Assignment
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment