Wednesday

Important Questions for Class 12 Computer Science (C++) – C++ Revision Tour

 

Topic – 1
Fundamentals

Previous Years Examination & Important Questions
2 Marks Questions

Question 1:
Write the type of C++ tokens (keywords and user defined identifiers) from the following: All Indio 2017

  1. new
  2. While
  3. case
  4. Num_2

Аnswer:

  1. new → keyword
  2. While → user defined identifier
  3. case → keyword
  4. Num_2 → user defined identifier

Question 2:
Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a C++ program: Delhi 2016
Cost, Price*Qty, float, Switch, Address One. Delete, Number12, do
Аnswer:
Price*Qty, float, do and Address One cannot be used for naming variables, constants or functions in a C++ program.

Question 3:
Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined. Delhi 2016
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;
}

Аnswer:

The correct code is:
#define Equation(p,q)(P+2*Q)
void main()
{
float A=3.2,B=4.1; 
float C=Equation(A,B); 
cout<<"0utput ="<<C<<endl;
}

Question 4:
Out of the following, find those identifiers, which cannot be used for naming Variables, Constants or Functions in a C++ program: All India 2016
Fatal*Tax, double, Case, My Name, NeW, switch, Column31,_Amount
Аnswer:
Fatal*Tax, double, My Name, switch cannot be used for naming variables, constants or functions in a C++program.

Question 5:
Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined. All India 2016
NOTE Assume all required header files are already
being included in the program.

#define Formula(a,b)=2*a+b 
void main()
{
float X=3.2;Y=4.1;
Z=Formula(X,Y);
cout<<'Result='<<Z<<endl;
}

Аnswer:

The correct code is:
#define Formula(a.b)(2*a+b)
void main()
{
float X=3.2.Y=4.1: 
float Z=Forinula(X.Y): 
cout<<"Result="<<Z<<endl:
}

Question 6:
Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined. All Indio 2016C NOTE Assume all required header files are already
being included in the program.

define formula(a,b,c)a+2*b+3*c; 
void main()
{
int L=1,M=2,N=3,
J=Formula(L,M,N); 
cout<<'output ='<<J<<endl;
}

Аnswer:

The correct code is:
#define Formula(a,b,c)a+2*b+3*c 
void main()
{
int L=1,M=2,N=3:
int J=formula(L,M,N);
cout<<"0utput="<<j<<endl;
}

0 comments:

Post a Comment

Thanks for leaving a comment. As soon as it's approved, it will appear.