Decision making in C

Decision making in C

University

10 Qs

quiz-placeholder

Similar activities

Control Statements

Control Statements

University

10 Qs

Tech Quiz

Tech Quiz

University

10 Qs

Unit 5 : Decision Control in C

Unit 5 : Decision Control in C

University

6 Qs

Recursion

Recursion

University

8 Qs

Coding Fundamentals in C

Coding Fundamentals in C

6th Grade - Professional Development

12 Qs

C++ Switch Statement

C++ Switch Statement

University

15 Qs

Quiz on Basics of C

Quiz on Basics of C

University

10 Qs

C programming

C programming

University

15 Qs

Decision making in C

Decision making in C

Assessment

Quiz

Computers

University

Medium

Created by

Dr. Singh

Used 4+ 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?

Discover more resources for Computers