C debugging Qs

C debugging Qs

University

8 Qs

quiz-placeholder

Similar activities

C program quiz 1

C program quiz 1

University

10 Qs

OCS752_CP_MODEL 1_PART B (16.10.2020)

OCS752_CP_MODEL 1_PART B (16.10.2020)

University

10 Qs

C Pointer

C Pointer

University

7 Qs

Operators in C(29/08)

Operators in C(29/08)

University

10 Qs

B2B: Intro to C

B2B: Intro to C

University

10 Qs

C - Pointers

C - Pointers

University

10 Qs

Basics Of C Programming

Basics Of C Programming

University

10 Qs

Coding Fundamentals in C

Coding Fundamentals in C

6th Grade - Professional Development

12 Qs

C debugging Qs

C debugging Qs

Assessment

Quiz

Computers

University

Hard

Created by

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.