
C debugging Qs

Quiz
•
Computers
•
University
•
Hard
Ajitha Padmanabhan
Used 3+ times
FREE Resource
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.
8.
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);
printf("You entered: %d", num);
return 0;
}
Enter a number : 5
5
5
error
none of the choice mentioned
Answer explanation
scanf requires the address of the variable.
Similar Resources on Wayground
9 questions
IPC144 -- Midterm Review

Quiz
•
University
10 questions
FLASH

Quiz
•
University
10 questions
C quiz

Quiz
•
University
13 questions
C Programming (Arttırma ve Azaltma Operatörleri)

Quiz
•
University
10 questions
AFP Midtvejsevaluering

Quiz
•
University
10 questions
Epics-2024

Quiz
•
University
6 questions
sample qizz

Quiz
•
University
10 questions
c basic

Quiz
•
University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University