Search Header Logo

Decision and Case Control Statements in C

Authored by vinay agrawal

Computers

University

Used 177+ times

Decision and Case Control Statements in C
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

35 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int x = 5;

if (x < 1)

printf("hello");

if (x == 5)

printf("hi");

else

printf("no");

}

hi

hello

no

error

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int x = 0;

if (x == 1)

if (x == 0)

printf("inside if\n");

else

printf("inside else if\n");

else

printf("inside else\n");

}

inside if

inside else if

inside else

compile time error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int x = 0;

if (x == 1)

if (x >= 0)

printf("true\n");

else

printf("false\n");

}

Depends on the compiler

No print statement

True

False

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The output of the following segment is

int k, n=20;

k=(n>5?(n<=10?100:200):500);

printf("%d",n);

100

200

300

20

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 1, b = 1;

switch (a)

{

case a*b:

printf("yes ");

case a-b:

printf("no\n");

break;

}

}

yes

no

yes no

compile time error

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result after execution of the following code if a is 10, b is 5, and c is 10?

if ((a > b) && (a <= c))

a = a + 1;

else

c = c+1;

a = 10, c = 10

a = 11, c = 10

a = 10, c = 11

a = 11, c = 11

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Output of the following code


#include <stdio.h>

int main()

{ int i = 0;

switch (i)

{

case '0': printf("Geeks");

break;

case '1': printf("Quiz");

break;

default: printf("GeeksQuiz");

}

return 0;

}

Geeks

Quiz

GeeksQuiz

None of the above

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?