CBSE computer and communication technology
Sponsor Area
Find the correct identifiers out of the following, which can be used for naming variables, constants or functions in a C++ program:
While, for, Float, new, 2ndName, A%B, Amount2, _Counter
Identifiers which can be used for naming variables constants in a C++ program are given below:
While, Float, Amount2, _Counter
Sponsor Area
Observe the following program very carefully and write the names of those header files (s), which are essentially needed to compile and execute the following program successfully :
typedef char TEXT[80];
void main()
{
TEXT Str[] = 'Peace is supreme';
int Index=0;
while (Str[Index]!='\0'){
if (isupper(Str[Index])){
Str[Index++]='#';
}
else{
Str[Index++]='*';
}
}
puts(Str);
}
The header files, which are essential to compile and execute the given code are:
- ctype
- Stdio
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 Max=70.0;
Void main()
{
int Speed
char Stop='N';
cin>>Speed;
if Speed>Max
Stop='Y';
cout<<Stop<<end;
}
#define Max 70.0 //Error 1,2,3
void main() //Error 4
{
int Speed; //Error 5
char Stop='N';
cin>>Speed;
if (Speed>Max){ //Error 6
Stop='Y';
}
cout<<Stop<<endl; //Error 7
}
Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
void Position(int & C1,int C2=3)
{
C1+=2;
C2+=Y;
}
void main()
{
int P1=20, P2=4;
Position(P1);
cout<<P1<<','<<P2<<end1;
Position(P2,P1);
cout<<P1<<','<<P2<<end1;
}
Output:
22,4
22,6
Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
class Calc
{
char Grade;
int Bonus;
public:
Calc() {Grade='E';Bonus=0;}
void Down(int G)
{
Grade-=G;
}
Void Up(int G)
{
Grade+=G;
Bonus++;
}
void Show()
{
cout<<Grade<<'#'<<Bonus<<end1;
}
};
void main()
{
Calc c;
C.Down(2);
C.Show();
C.Up(7);
C.Show();
C.Down(2);
C.Show();
}
Output:
C#0
J#1
H#1
Sponsor Area
Mock Test Series
Mock Test Series



