wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

OPERATORS QUIZ C

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.

Which of the following is the correct structure of a C program?

a)

Documentation, Linking, Definition, Global Declaration, Main Function, Sub Programs

b)

Documentation, Definition, Linking, Global Declaration, Main Function, Sub Programs

c)

Documentation, Linking, Definition, Global Declaration, Sub Programs, Main Function

d)

Definition, Documentation, Linking, Global Declaration, Main Function, Sub Programs

2.

What is the entry point of a C program?

a)

start()

b)

begin()

c)

main()

d)

program()

3.

Which of the following is a valid identifier in C?

a)

2variable

b)

variable_name

c)

var-name

d)

var name

4.

Which of the following is not a valid identifier?

a)

myVar

b)

_var123

c)

123var

d)

var_123

5.

Which of the following is a keyword in C?

a)

function

b)

define

c)

return

d)

begin

6.

Which of the following is the correct way to declare a variable in C?

a)

int variable;

b)

int variable:

c)

int variable{};

d)

int variable()

7.

Which of the following is true about variables in C?

a)

Variables can be declared without specifying a data type.

b)

Variable names can start with a digit.

c)

Variables can be declared anywhere in the program before they are used.

d)

Variables do not need to be initialized before use.

8.

Which of the following is not a basic data type in C?

a)

int

b)

float

c)

double

d)

string

9.

Which of the following data types has the highest precision?

a)

int

b)

float

c)

double

d)

char

10.

Which function is used to read formatted input from the standard input in C?

a)

printf()

b)

scanf()

c)

gets()

d)

puts()

11.

Which of the following format specifiers is used to print a floating-point number?

a)

%d

b)

%c

c)

%f

d)

%s

12.

How would you print a string in C?

a)

printf("%d", str);

b)

printf("%c", str);

c)

printf("%s", str);

d)

printf("%f", str);

13.

Which of the following code snippets contains a valid identifier?

a)

The code contains a valid identifier.

b)

The code does not contain a valid identifier.

14.

Which of the following code snippets correctly uses a keyword in C?

a)

The code correctly uses a keyword.

b)

The code does not correctly use a keyword.

15.

What will be the output of the following C program?

a)

error

b)

10

c)

default value

d)

nothing will be printed

16.

What will be the output of the following C program?

a)

Value = 5.2

b)

Value = 5.25

c)

Value = 5

d)

Value = 5.250000

17.

What will be the output of the following C program?

a)

Enter your name: Hello, [input]

b)

Enter your name: [input] Hello,

c)

Hello, [input]

d)

The code will produce a compilation error.

18.

What will be the output of the following C program?

a)

a = 10, b = 20

b)

a = 20, b = 10

c)

a = 1020, b = 2010

d)

The code will produce a compilation error.

19.

What will be the output of the following C program?

a)

a = 5, b = 5.5

b)

a = 5, b = 5

c)

a = 5, b = 5.50

d)

The code will produce a compilation error.

20.

What will be the output of the following C program?

a)

Result = 3

b)

Result = 3.5

c)

Result = 3.0

d)

The code will produce a compilation error.

21.

What will be the output of the following C program?

a)

10

b)

0

c)

Garbage value

d)

Compilation error

22.

What will be the output of the following C program?

a)

5 5

b)

6 5

c)

5 6

d)

6 6

23.

What will be the output of the following C program?

a)

16

b)

13

c)

11

d)

10

24.

What will be the output of the following C program?

a)

0

b)

1

c)

3

d)

5

25.

What will be the output of the following C program?

a)

0

b)

1

c)

3

d)

5

26.

What will be the output of the following C program?

a)

1

b)

3

c)

5

d)

7

27.

What will be the output of the following C program?

a)

5

b)

10

c)

0

d)

15

28.

What will be the output of the following C program?

a)

10

b)

0

c)

Garbage value

d)

Compilation error

29.

What will be the output of the following C program? #include int main() { int a = 10; int *p = &a; printf("%d\n", *p); return 0; }

a)

10

b)

Address of a

c)

Garbage value

d)

0

30.

What will be the output of the following C program? #include int main() { int a = 5, b = 10, c = 15; int result = a + b * c / b - a; printf("%d\n", result); return 0; }

a)

10

b)

12

c)

15

d)

20

31.

What will be the output of the following C program? #include int main() { int a = 10; int b = 20; int c = a + b; printf("%d\n", c); return 0; }

a)

10

b)

20

c)

30

d)

0

32.

#include int main() { int x = 10, y = 5, z = 0; z = x++ + ++y; printf("%d", z); return 0; }

a)

15

b)

16

c)

17

d)

18

33.

What is the output of the following code? #include int main() { int a = 7, b = 3; printf("%d", a / b); return 0; }

a)

2

b)

2.33

c)

3

d)

3.5

34.

What will be the output of the following code? #include int main() { int a = 5; printf("%d", a == 5); return 0; }

a)

0

b)

1

c)

5

d)

-1

35.

Which of the following is the correct order of precedence (from highest to lowest) of the given operators?

a)

+, *, &&, ||

b)

*, +, &&, ||

c)

&&, ||, +, *

d)

||, &&, +, *

36.

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

a)

1

b)

2

c)

3

d)

5

37.

What will be the value of x after executing the following code? #include int main() { int x = 5; x = x + 3 * 2; printf("%d", x); return 0; }

a)

11

b)

13

c)

16

d)

10

38.

What is the output of the following code? #include int main() { int a = 10, b = 20, c = 30; printf("%d", (a < b) && (b > c) || (a == c)); return 0; }

a)

0

b)

1

c)

-1

d)

10

39.

What will be the output of the following code? #include int main() { int x = 10, y = 3; int result = x % y; printf("%d", result); return 0; }

a)

1

b)

3

c)

10

d)

0

40.

Which operator is used to perform bitwise OR in C?

a)

|

b)

||

c)

&

d)

&&

41.

What is the output of the following code? #include int main() { int a = 5, b = 10, c; c = (a > b) ? (a - b) : (b - a); printf("%d", c); return 0; }

a)

5

b)

10

c)

-5

d)

0

42.

What will be the result of the following expression in C? int a = 5; float b = 2.5; float c = a + b;

a)

7.5

b)

7

c)

5.0

d)

Compilation error

43.

What happens when an int and a double are used together in an arithmetic expression?

a)

The int is promoted to a double

b)

The double is demoted to an int

c)

The result is always an int

d)

Compilation error

44.

What will be the value of b after the following code is executed? int a = 10.5; int b = a;

a)

10

b)

10.5

c)

Undefined

d)

Compilation error

45.

What will happen if we assign a float value to an int variable?

a)

The value will be rounded off

b)

The value will be truncated

c)

The value will remain the same

d)

Compilation error

46.

What is the result of the following code? float a = 9.8; int b = (int)a;

a)

9.8

b)

10

c)

9

d)

Compilation error

47.

When a double value is converted to an int, what happens to the fractional part?

a)

It is rounded to the nearest integer

b)

It is truncated

c)

It causes a compilation error

d)

It remains as is

48.

What will be the output of the following code? int a = 5, b = 2; float c = (float)a / b;

a)

2.5

b)

2.0

c)

2

d)

Compilation error

49.

What does the following expression evaluate to? int a = 7; int b = 2; double c = (double)(a / b);

a)

3.5

b)

3.0

c)

3

d)

Compilation error

50.

What will be the output of the following code? char a = 100; int b = 50000; long c = a + b; printf("%ld", c);

a)

50100

b)

50100L

c)

50100.0

d)

Compilation error

51.

Given the following code, what is the value of result? short a = 5; float b = 3.2; double result = a * b;

a)

16

b)

16.0

c)

16.0f

d)

Compilation error

52.

What is the output of the following code? unsigned int a = 3; int b = -4; printf("%u", a + b);

a)

-1

b)

4294967295

c)

4294967299

d)

Compilation error

53.

Determine the output: int a = 2147483647; unsigned int b = 1; printf("%d", a + b);

a)

-2147483648

b)

2147483648

c)

0

d)

Compilation error

54.

What is the value of x after this code executes? double x = 10.75; int y = x; x = y;

a)

10

b)

10.75

c)

11

d)

Undefined

55.

What is the output of the following code? float a = 3.14; int b = a; printf("%d", b);

a)

3

b)

3.14

c)

4

d)

Compilation error

56.

What will be the value of y after the execution of this code? unsigned char x = 255; int y = x;

a)

255

b)

-1

c)

255U

d)

Compilation error

57.

What will be the value of b after the following code is executed? double a = 5.5; int b = (int)a;

a)

5

b)

5.5

c)

6

d)

Undefined

58.

What is the value of b after the following code is executed? double a = 12.999; int b = (int)a;

a)

12

b)

13

c)

12.999

d)

Compilation error

59.

What is the output of this code? float a = 4.75; int b = a; printf("%d", b);

a)

4

b)

5

c)

4.75

d)

Compilation error

60.

What is the output of the following code? double a = 2.71828; int b = (int)a; printf("%d", b);

a)

2

b)

3

c)

2.71828

d)

Compilation error

61.

What will be the result of this code? double x = -7.999; int y = (int)x;

a)

-8

b)

-7

c)

-7.999

d)

Compilation error

62.

What is the result of this code? int a = 7; int b = 3; float c = (float)a / b;

a)

2.333333

b)

2

c)

2.0

d)

Compilation error