wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming MCQ Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

How many times "ASOFTLAB" is get printed? #include int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break; printf("ASOFTLAB"); } return 0; }

a)

Infinite times

b)

11 times

c)

0 times

d)

10 times

2.

In mathematics and computer programming, which is the correct order of mathematical operators?

a)

Addition, Subtraction, Multiplication, Division

b)

Division, Multiplication, Addition, Subtraction

c)

Multiplication, Addition, Division, Subtraction

d)

Addition, Division, Modulus, Subtraction

3.

What is the output of the following C program? #include int main() { printf("%lu", sizeof(int)); return 0; }

a)

2

b)

4

c)

8

d)

16

4.

What is the output of the following program? #include main() { printf("\"); }

a)

- \

b)

- "

c)

- "

d)

- Compile error

5.

Compiler generates ___ file.

a)

- Executable code

b)

- Object code

c)

- Assembly code

d)

- None of the above.

6.

The return keyword used to transfer control from a function back to the calling function.

a)

- Yes

b)

- Switch

c)

- go back

d)

- goto

7.

What is the output of the following code snippet? #include main() { int const a = 5; a++; printf("%d",a); }

a)

- 5

b)

- 6

c)

- Runtime error

d)

- Compile error

8.

What is the output of the below code snippet? #include main() { int a = 5, b = 3, c = 4; printf("a = %d, b = %d\n", a, b, c); }

a)

- a=5, b=3

b)

- a=5, b=3, c=0

c)

- a=5, b=3, 0

d)

- compile error

9.

What is the output of the following code snippet? #include main() { int x = 5; if(x=5) { if(x=5) printf("Hello"); } printf("Hi"); }

a)

- HelloHi

b)

- Hi

c)

- Hello

d)

- Compiler error

10.

What is the output of the following program? #include void f() { printf("Hello\n"); } main() { ; }

a)

- No output

b)

- Error, as the function is not called.

c)

- Error, as the function is defined without its declaration

d)

-Error, as the main() function is left empty

11.

What will be the output of the following code? #include int add(int a, int b) { return a + b; } int main() { printf("%d", add(2, 3)); return 0; }

a)

2

b)

5

c)

3

d)

Error

12.

What will be the output of this code? #include int main() { int arr[] = {1, 2, 3}; printf("%d", arr[1]); return 0; }

a)

1

b)

2

c)

3

d)

Error

13.

What will be the output of this code? #include int main() { char str[] = "Hello"; printf("%s", str); return 0; }

a)

Hello

b)

H

c)

Error

d)

hello

14.

What will be the output? #include int main() { int x = 10; int *p = &x; printf("%d", *p); return 0; }

a)

10

b)

0

c)

Error

d)

Garbage value

15.

What will be the output? #include int main() { for (int i = 1; i <= 2; i++) { for (int j = 1; j <= 2; j++) { printf("%d ", i + j); } } return 0; }

a)

2 3 2 3

b)

2 3 3 4

c)

1 2 1 2

d)

Error