Search Header Logo

C Programming Control Structures Quiz

Authored by Sriram Nagarajan

Science

University

C Programming Control Structures Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax for a `while` loop in C?

`while (condition) { // code }`

`while { condition } ( // code )`

`loop while (condition) { // code }`

`while condition { // code }`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which keyword is used to exit a loop immediately in C?

`exit`

`stop`

`break`

`return`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? ```c int i = 0; do { printf("%d ", i); i++; } while (i < 3); ```

`0 1 2 3`

`1 2 3`

`0 1 2`

`0 1 2 3 4`

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax for an `if-else` statement in C?

`if (condition) { } else { }`

`if condition { } else { }`

`if (condition) then { } else { }`

`if { condition } else { }`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the `continue` statement do in a loop in C?

Terminates the loop entirely

Skips the current iteration and moves to the next iteration

Restarts the loop from the beginning

Pauses the loop execution

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Analyze the following code. What will be the final value of `sum` after execution? ```c int sum = 0; for (int i = 1; i <= 10; i++) { if (i % 2 == 0) continue; sum += i; } ```

`55`

`30`

`25`

`20`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following nested loop. How many times will `printf` execute? ```c for (int i = 0; i < 3; i++) { for (int j = i; j < 3; j++) { printf("*"); } } ```

`9`

`6`

`3`

`12`

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

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?