Questions – Exam Papers – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Question Typewise Collection-"Code Error Finding" Questions - Exam Papers (CPP) No. of Q.18
Q.1   Exam - CBSE12D-2016/01C/2

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;
}


Q.2   Exam - CBSE12D-2017/01C/2

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.

void main()
{
  cout<<"Enter an integer";
  cin>>N;
  switch(N%2)
  case 0 cout<<"Even"; Break;
  case 1 cout<<"Odd" ; Break;
}


Q.3   Exam - CBSE12A-2015/01C/2

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;
}


Q.4   Exam - CBSE12D-2015/01C/2

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;
}


Q.5   Exam - CBSE12A-2016/01C/2

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 Formula(a,b) = 2*a+b
void main()
{
  float X=3.2;Y=4.1;
  Z=Formula(X,Y);
  cout<<'Result='<<Z<<endl;
}



Rewrite the following program after removing possible compiler errors. Mark each correction by underlining it. Assume that relevant header files are included.

int main()
{
  const int d 5;
  number = 15;
  for(int i=1; i<=5; i++, number-=3)
    if(number%d==0) cout<<number/d<<" ";
    else cout<<number+d<<" ";
}



Find errors in the following code and explain. Assume that required header files are present.

main()
{
  cout<<endl<<a;
  return 0;
}


Q.8   Exam - CBSE12A-2017/01C/2

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.

void main()
{
cout<<"Enter an Alphabet:";
cin>>CH;
switch(CH)
case ‘A’ cout<<"Ant"; Break;
case ‘B’ cout<<"Bear" ; Break;
}


Q.9   Exam - CBSE12A-2018/01C/2

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.
Note : Assume all required header files are already included in the program.

 

Typedef Count int;
void main()
{
  Count C;
  cout<<"Enter the count:";
  cin>>C;
  for (K = 1; K<=C; K++)
    cout<< C "*" K <<endl;
}



Identify errors in the following program. assume that appropriate header files are included.

int main()
{
  x=1;
  for(int j=10; j>5; j--) 
  cout>>x;
  return 0;
}



Find error (if any) in the following class definition.

Class PLAY
{
  int number_of_actors=5;
  void set_actor_count()
  {
    number_of_actors=10;
  }
};



Find syntactical errors in the following program and rewrite the program after underlining the corrected portion.

#include<iostreamh>
using namespace std;
void toUpper(char x) {return ((char) (x+1));}
main()
{
char c, String[]=”DOGS ARE NOT CATS”;
for(int i=0;String[i]!=;i++)
if(String[i]==’ ‘) cout<<endl;
else { c=toUpper(String[i]);cout<<c;}
return 0;
}




A student has written this program to sum natural numbers from 1 to 10. His program is not giving correct results. Please help in correcting this program with right explanations as well.




Find error in the following program and suggest corrections. Assume that includes and namespace is already given.




There are some errors in the following code due which the expected output as given below will not come
“C++” is tricky & powerful

 




Find the errors in the following code and explain.




Find errors in the following program and write the program with correct syntax.




Following program may compile and link well but still it may not serve the desired purpose. Find the error.