CBSE eBooks
CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK
Chapter – 1 C++ Revision Tour

1. c. Rewrite the following program after removing the syntactical error(s) if any. Underline each correction. 2
#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];
}
1. e. Find the output of the following program. 3
#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

Computer Science By Mr. MRK
|