wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Lab Quiz-1

Total questions: 19

Worksheet time: 15mins

Name
Class
Date
1.

What will happen when this program is executed?

int i = 1;

while(i <= 5)

{

if(i == 3)

continue;

printf("%d ", i);

i++;

}

a)
1 2 3 4
b)
1 3 4 5
c)

infinite loop

d)

compile time error

2.

What will be the output?(type your answer)

int count = 0;

for(int i = 1; i <= 4; i++)

{

for(int j = i; j <= 4; j++)

{

count++;

}

}

printf("%d", count);

(a)  

3.

What will be the output(count value)?

int count = 0;

for(int i = 1; i <= 3; i++)

{

for(int j = 1; j <= 5; j++)

{

if(j == i)

break;

count++;

}

}

printf("%d", count);

a)
4
b)
3
c)
5
d)
2
4.

What will be the output?

#include <stdio.h>

int main(){

int i;

i = 1, 2, 3;

printf("i = %d\n", i);

return 0;

}

a)
i = 2
b)
i = 3
c)
i = 1
d)
i = 0
5.

What will be the output?

int a = 5, b = 10, c;

c = (a > b) ? a : (b > 7 ? b : 7);

printf("%d", c);

a)
5
b)
7
c)
15
d)
10
6.

int a = 1, b = 2;

switch(a + b)

{

case 1:

printf("One");

break;

case 3:

printf("Three");

break;

case 1 + 2:

printf("Again Three");

break;

default:

printf("Default");

}

a)

Three

b)

Again Three

c)

Default

d)

Compilation Error

7.

Which of the following is a valid declaration?

a)

int 1num;

b)

float num;

c)

char 9c;

d)

double-int x;

8.

What would be output?

int a = 10;

float b = 3;

printf("%f", a / b);

a)

3.0

b)
3.333333
c)

3.33

d)

3

9.

What would be output?

int x = 1;

if(x == 1)

printf("A");

if(x == 1)

printf("B");

else

printf("C");

a)
AC
b)
BC
c)
AA
d)
AB
10.

int i = 1;

while(i <= 5);

{

printf("%d ", i);

i++;

}

a)
The value of i is printed as 1.
b)

1 2 3 4 5

c)

Infinite loop.

d)
The loop runs five times.
11.

What would be output?

for(int i = 1; i <= 5; i++)

{

if(i == 3)

continue;

printf("%d ", i);

}

a)
1 3 4 5
b)
1 2 4 5
c)
2 3 4 5
d)
1 2 3 4
12.

int i = 1;

while(i++ <= 3){

printf("%d ", i);

}

a)
3 4 5
b)
1 2 3
c)
2 3 4
d)
0 1 2
13.

char x = 120;

while(x > 0)

{

printf("%d ", x);

x++;

}

a)

Infinite loop

b)

Prints 120 to 127

c)

Prints 120 to 255

d)

INo output

14.

Which of the following sequences correctly represents the stages involved when a C program is executed?

a)

Source Code → Compiler → Preprocessor → CPU → Output

b)

Source Code → Preprocessor → Compiler → Linker → Loader → CPU → Output

c)

Source Code → Compiler → Linker → Preprocessor → CPU → Output

d)

Source Code → Preprocessor → CPU → Compiler → Output

15.

What would be outpu t( Assume that during runtime you have taken input as 6 in your scanf function) ?

#include <stdio.h>

int main(){

int x;

int a, b;

a = printf("Hello");

b = scanf("%d", &x);

printf("%d", a + b);

return 0;

}

a)
7
b)
6
c)
5
d)
8
16.

When your C program does NOT give the expected output, what is the first thing you do?

a)

Stare at the screen silently and rethink life choices

b)

Run it again, because maybe the computer didn’t understand you the first time

c)

Look at the professor and pretend it’s “almost correct”

d)

Blame the compiler version

17.

What would be output?

int a = 5, b = 2;

int c;

c = a * b + a / b;

printf("%d", c);

(a)  

18.

int x = 0;

while(x = 5)

{

if(x == 3)

break;

printf("%d ", x);

x--;

}

a)

Compilation error

b)

5 4 3

c)

5 4 3 2 1

d)

Infinite loop

19.

What do you expect most from your C programming professor?

a)

Clear explanations with simple examples

b)

More hands-on coding and lab practice

c)

Help in understanding logic and problem-solving

d)

Support for exams, interviews, and real-world applications

e)

Just leave us early from programming class