CBSE computer and communication technology
Sponsor Area
Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a C++ program:
_Cost, Price*Qty, float, Switch,
Address One, Delete, Number12, do
Price*Qty, Address One, do and float is cannot be used for naming variable, constants or Functions in a C++ program.
Sponsor Area
Jayapriya has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.
void main()
{
float A,Number,Outcome;
cin>>A>>Number;
Outcome=pow(A,Number);
cout<<Outcome<<endl;
}
Missing header files,
(i) (iostream.h
(ii) math.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.
#define Equation(p,q) = p+2*q
void main()
{
float A=3.2;B=4.1;
C=Equation(A,B);
cout<<'Output='<<C<<endl;
}
#define Equation(p,q) p+2*q
void main()
{
float A=3.2 , B=4.1;
float C=Equation(A,B);
cout<< ”Output=” <<C<<endl;
}
Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.
typedef char STRING[80];
void MIXITNOW(STRING S)
{
int Size=strlen(S);
for (int I=0;I<Size1;I+=2)
{
char WS=S[I];
S[I]=S[I+1];
S[I+1]=WS;
}
for (I=1;I<Size;I+=2){
if (S[I]>='M' && S[I]<='U'){
S[I]='@';
}
}
void main()
{
STRING Word='CRACKAJACK';
MIXITNOW(Word);
cout<<Word<<endl;
}
}
Output: RCCAAKAJKC
Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
class Stock
{
long int ID;
float Rate; int Date;
public:
Stock(){ID=1001;Rate=200;Date=1;}
void RegCode(long int I,float R)
{
ID=I; Rate=R;
}
void Change(int New,int DT)
{
Rate+=New; Date=DT;
}
void Show()
{
cout<<'Date :'<<Date<<endl;
cout<<ID<<'#'<<Rate<<endl;
}
};
void main()
{
Stock A,B,C;
A.RegCode(1024,150);
B.RegCode(2015,300);
B.Change(100,29);
C.Change(20,20)
;
A.Show();
B.Show();
C.Show();
}
Output:
Date :1
1024#150
Date :29
2015#400
Date :20
1001#180
Sponsor Area
Mock Test Series
Mock Test Series



