wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What is the purpose of the #include directive in a C program?

a)

To include a library file.

b)

To define a library file.

c)

To define a constant.

d)

To start the main function.

2.

An interpreter reads the source code of a program

a)

one line at a time

b)

two lines at a time

c)

complete program in one stroke

d)

None of these

3.

Choose the correct statements from the following:

 i) C is an object oriented programming language.

ii) C programs are highly portable on any type of operating system platform.

iii) A flowchart is a visual representation of the sequence of steps for solving a problem.

iv) The role of a compiler is to translate source program statements to decimal codes.

a)

(i) and (ii)

b)

(ii) and (iii)

c)

(i), (ii), and (iii)

d)

(ii), (iii), and (iv)

4.

What will be the output for the given code? #include int main() { char c = 'B'; printf("%c", c + 32); return 0; }

a)

b

b)

Y

c)

Z

d)

d

5.

What will be the output for the given code? #include int main() { int a = 4; printf("%d", a == 4 && a < 5); return 0; }

a)

0

b)

1

c)

4

d)

-1

6.

What will be the output for the given code? #include int main() { int x = 2, y = 3, z; z = x > y ? x*x : x+y; printf("%d", z); return 0; }

a)

2

b)

3

c)

5

d)

1

7.

Predict the output: #include int main() { int a = 8, b = 3; printf("%d", a % b * a / b); return 0; }

a)

8

b)

9

c)

5

d)

10

8.

Predict the output: #include int main() { char ch = 'A'; printf("%d", ch + 3); return 0; }

a)

65

b)

68

c)

C

d)

D

9.

Guess the output of the given code: #include int main() { float x = 7/2; printf("%.2f", x); return 0; }

a)

3.5

b)

3.0

c)

3.50

d)

3

10.

What is the output of the given code?

#include<stdio.h>

int main() {

int a = 5, b = 3;

printf("%d", a++ + ++b); return 0; }

a)

8

b)

9

c)

10

d)

11

11.

Which of the following is not a correct expression in C?

a)

a + b * c

b)

a = b = c

c)

(a > b) && (b > c)

d)

a = (b+c) * / d

12.

In C, which function is used for formatted input?

a)

scanf()

b)

printf()

c)

gets()

d)

puts()

13.

Which operator is used to access the address of a variable?

a)

&

b)

*

c)

->

d)

%

14.

Which of the following is a valid variable name in C?

a)

float-rate

b)

int 2value

c)

_count

d)

long double

15.

Which of the following is a valid constant in C?

a)

int a = 10;

b)

const int a = 10;

c)

float x;

d)

keyword const;

16.

Which of the following character sets are used in C?

a)

Alphabets, Digits, Special Symbols, Whitespace

b)

Alphabets only

c)

Digits only

d)

ASCII values only

17.

Which of the following is NOT a C keyword?

a)

int

b)

else

c)

Char

d)

if

18.

Which operator has the highest precedence in C?

a)

* (Multiplication)

b)

++ (Increment)

c)

() (Parentheses)

d)

&& (Logical AND)

19.

What is the size of the float data type in C?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

Depends on compiler

20.

What will be the output of the following code?

#include<stdio.h>

int main()

{ int a = 9, b = 2;

printf("%f", (float)a / b); return 0;}

a)

4.5

b)

4

c)

5

d)

4.0

21.

What will be the output of the following code?

#include<stdio.h>

int main(){

int a = 9, b = 3;

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

return 0; }

a)

5

b)

4

c)

1

d)

0

22.

What will be the output of the following code? #include <stdio.h>

int main() {

int a = 10, b = 4;

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

return 0; }

a)

6

b)

14

c)

10

d)

1

23.

What will be the output of the following code?

#include<stdio.h>

int main(){

int a = 10;

printf("%d", a<<2);

return 0; }

a)

10

b)

40

c)

20

d)

15

24.

What will be the output of the following code? #include<stdio.h>

int main(){

int a = 4;

printf("%d", a>>1);

return 0; }

a)

6

b)

4

c)

8

d)

2

25.

What will be the output of the following code? #include <sttdio.h>

int main(){

int x=10, y=5;

printf("%d", x|y );

return 0; }

a)

6

b)

15

c)

5

d)

1