0% found this document useful (0 votes)
389 views

C Debugging Quiz

1. The C-Debugging quiz contains multiple choice questions to test knowledge of debugging errors in C code. Questions cover errors related to variable declarations, operator precedence, conditional statements, and pointer usage. 2. The document provides explanations for code snippets that contain errors or produce unexpected output. Semicolons missing at the end of statements are identified as errors. 3. The quiz assesses understanding of basic C syntax, data types, operators, and debugging logical errors in if/else statements and expressions. Correct answers are given to help learn how to identify and fix common programming mistakes.

Uploaded by

Ricky
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
389 views

C Debugging Quiz

1. The C-Debugging quiz contains multiple choice questions to test knowledge of debugging errors in C code. Questions cover errors related to variable declarations, operator precedence, conditional statements, and pointer usage. 2. The document provides explanations for code snippets that contain errors or produce unexpected output. Semicolons missing at the end of statements are identified as errors. 3. The quiz assesses understanding of basic C syntax, data types, operators, and debugging logical errors in if/else statements and expressions. Correct answers are given to help learn how to identify and fix common programming mistakes.

Uploaded by

Ricky
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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.

3. Convert the following algebraic expressions into equivalent C 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.

5. In C **operator is used for exponentiation Operation.


Answer : False.

6. The expression x= -7 % 2 - 8 would evaluate to –9 .

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 .

10. Point out the error, if any, in the following program.

#include <stdio.h>
int main()
{
int code, flag ;
if ( Code == 1 & flag == 0 )
printf ( " The eagle is handled \n”) ;
return 0;
}

Error To Combine two conditions Use && and not & .

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

13. Which of the following return-type cannot be used for a function in C?


a) char*
b) struct
c) void
d) none of the mentioned.

Answer : d

14. What is the Size of (char) in a 32 bit C Complier ?


a) I bit
b) 2 bit
c) 1 Byte
d) 2 Bytes

Answer : c

You might also like