Decision making in C

Decision making in C

University

10 Qs

quiz-placeholder

Similar activities

FLASH

FLASH

University

10 Qs

BASIC C QUIZ

BASIC C QUIZ

University

15 Qs

Decision control in Programming

Decision control in Programming

University

7 Qs

FIND THE KEY

FIND THE KEY

University

10 Qs

PPS : Quiz 2

PPS : Quiz 2

University

15 Qs

Coding and Debugging

Coding and Debugging

University

15 Qs

FIVIZZ: WEEK 11 - PROGRAMMING 2

FIVIZZ: WEEK 11 - PROGRAMMING 2

University

10 Qs

IPC144 -- Midterm Review

IPC144 -- Midterm Review

University

9 Qs

Decision making in C

Decision making in C

Assessment

Quiz

Computers

University

Medium

Created by

Dr. Singh

Used 5+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

  1. What is the correct syntax for an if statement in C?

if condition { /* code to execute */ }
if (condition) /* code to execute */
if { condition } { /* code to execute */ }
if (condition) { /* code to execute */ }

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

  1. Which of the following statements is true about the else if construct?

The 'else if' construct can only be used once in a program.
The 'else if' construct does not allow for nested conditions.
The 'else if' construct is only applicable in switch statements.
The 'else if' construct allows for multiple conditional checks.

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

  1. What will the following code print if x = 10?

    if (x < 5) {

    printf("Less than 5");

} else if (x < 15) {

    printf("Less than 15");

} else {

    printf("15 or more");

}

Exactly 10
Less than 5
Less than 15
15 or more

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

  1. In C, which of the following statements correctly implements a switch-case?

switch(expression) { case value1: // code block; default: // code block; }

switch(value) { case value1: // code block; case value2: // code block; }
switch(expression) { case value1: // code block; break; case value2: // code block; break; default: // code block; }
switch(expression) { case value1: // code block; break; case value2: // code block; continue; }

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What will the following code output if num is 3?

switch (num) {

    case 1:

        printf("One");

        break;

    case 2:

        printf("Two");

        break;

    default:

        printf("Default");

        break;

}

One
Three
Two
Default

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. Which of the following expressions is evaluated in an if statement in C?

Integer values only

Boolean values only

Any expression that evaluates to zero (false) or non-zero (true)

String literals only

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What is the output of the following code segment?

int a = 5, b = 10;

if (a > b)

    printf("A is greater");

else if (a < b)

    printf("B is greater");

else

    printf("A and B are equal");

A and B are equal
B is greater
A is greater
B is less than A

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?