C Debugging Quiz
C Debugging Quiz
1.
#include<stdio.h>
int main()
{
int a =35, float b =3.24;
printf ("%d %f %d", a, b+1.5, 235);
}
No error. The list being printed in printf() may contain Variables, Constants or expressions .
2.
#include <stdio.h>
int main()
{
int ml, m2, m3
printf ("Enter Values of marks in 3 subjects")
scanf (" %d %d %d", &m1, &m2, &m3)
printf (" you entered %d %d %d", m1, m2, m3);
}
Error. Semicolon should be present at the end of type declaration, printf() and scanf() Statements.
Z = [ ( x + 3 ). x. x. x ] / [ ( y - 4 ) ( y + 5 ) ]
Z=[(x+3)*x*x*x] / [(y–4)*(y+5)]
4.
#include <stdio.h>
int main()
{
float a =5 , b =2 ;
int c , d ;
c=a%b;
d=a/2;
printf ( " %d \n", d ) ;
return 0;
}
Output :
Error . mod(%) Operator cannot be used on floats.
7.
#include <stdio.h>
int main()
{
int a = 300, b, c ;
if (a >=400)
b = 300 ;
C = 200 ;
printf (" %d %d \n", b, c) ;
return 0;
}
Output :
b will contain some garbage value and C will be equal to 200.
8.
#include <stdio.h>
int main()
{
Int x = 3 ;
float y =3.0 ;
if ( x == y )
printf (" x and y are equal \n “) ;
else
printf("x and y are not equal \n ") ;
return 0;
}
Output :
x and y are equal.
9.
#include <stdio.h>
int main()
{
int i=65;
char j = 'A' ;
if ( i == j )
printf ( "C is wow \n " ) ;
else
printf ( "C is a headache \n " ) ;
return 0;
}
Output :
C is wow .
#include <stdio.h>
int main()
{
int code, flag ;
if ( Code == 1 & flag == 0 )
printf ( " The eagle is handled \n”) ;
return 0;
}
11.
#include <stdio.h>
int main()
{
int x = 4, y, z ;
y=--x ;
z=x-- ;
printf (" %d %d %d \n", x , y , z ) ;
retum 0 ;
}
Output :
233
12. How many against number of pointer (*) does C have against a pointer variable declaration ?
a)7
b) 127
c) 255
d) No limits.
Answer : d
Answer : d
Answer : c