Search Header Logo

C debugging Qs

Authored by Ajitha Padmanabhan

Computers

University

Used 3+ times

C debugging Qs
AI

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers