
C debugging Qs
Authored by Ajitha Padmanabhan
Computers
University
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Find the correct output :
#include <stdio.h>
int main(){
int x = 5;
printf("The value of x is: %d\n", x)
return 0;
}
Logical Error
Syntax Error
code is correct
Does not print anything
Answer explanation
Add a semicolon at the end of the printf line.
2.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
#include <stdio.h>
Choose the correct option:
int main() {
int a, b, sum;
a = 5;
b = 7;
sum = a + b;
printf("The sum of %d and %d is %d\n", a, b);
return 0;
}
Code is correct
Logical error
format error
syntax error
Answer explanation
The printf format specifier does not match the number of arguments.
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
choose the correct option:
#include <stdio.h>
int main() {
float result;
int num1 = 10, num2 = 3;
result = num1 / num2;
printf("The result is: %f", result);
return 0;
}
incorrect results
displays correct results
will not work
none of the mentioned
Answer explanation
The division is performed using integers, leading to incorrect results.
4.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
#include <stdio.h>
int main() {
int n;
printf("Enter a number: ");
scanf("%d", n);
if (n % 2 == 0)
printf("The number is even.");
else
printf("The number is odd.");
return 0;
}
Displays correct answer
Syntax error
logical error
None of the mentioned
Answer explanation
scanf requires the address of the variable.
5.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Choose the correct option:
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num > 0);
printf("The number is positive.");
return 0;
}
The number is postive
logical error
syntax error
none of the choice mentioned
Answer explanation
There's a semicolon at the end of the if statement.
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
#include <stdio.h>
int main() {
int a = 5, b = 0, result;
result = a / b;
printf("The result is: %d", result);
return 0;
}
Error
The result is 0
The result is 5
logical error
Answer explanation
Division by zero error
7.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
#include <stdio.h>
int main() {
int x = 10;
if (x = 5)
printf("x is equal to 5.");
else
printf("x is not equal to 5.");
return 0;
}
x is equal to 5
x is not equal to 5
5
Errror
Answer explanation
Assignment operator = instead of comparison operator == in the if condition.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Mini 2 (5junio)
Quiz
•
University
10 questions
Python-Quiz-Basic-Datatypes
Quiz
•
12th Grade - Professi...
12 questions
Python Quiz 1.4
Quiz
•
University
11 questions
Execl Quiz
Quiz
•
7th Grade - University
10 questions
ICT 1202-B-2021-Q1
Quiz
•
University
10 questions
Quiz 3
Quiz
•
University
10 questions
FOP - CHAPTER 4
Quiz
•
University
10 questions
Quiz 1
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade