wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

I/O and Operators in C

Total questions: 43

Worksheet time: 21mins

Name
Class
Date
1.

int x;

int y;

int z;

x=3;

y=4;

z = ++x * y++;

printf("%d",z);

a)

12

b)

16

c)

20

d)

0

2.

In C programming language, which of the following type of operators have the highest precedence

a)

Relational operators

b)

Equality operators

c)

Logical operators

d)

Arithmetic operators

3.

Which operator has the lowest priority?

a)

++

b)

%

c)

+

d)

||

4.

The modulus operator (%) can be used only with integers.

a)

True

b)

False

5.

#include <stdio.h>


int main()

{


int i = 95;


char c = 97;


printf("%d, %d\n", sizeof(i), sizeof(c));


return 0;

}

a)

2,1

b)

4,2

c)

2,4

d)

2,8

6.

#include <stdio.h>


void main()

{


int x = 5 * 9 / 3 + 9;


}

a)

24

b)

3

c)

23

d)

4

7.

In an expression involving || operator, evaluation

I. Will be stopped if one of its components evaluates to false

II. Will be stopped if one of its components evaluates to true

III. Takes place from right to left

IV. Takes place from left to right

a)

I and II

b)

I and III

c)

II and III

d)

II and IV

8.

#include <stdio.h>

int main() {

int y = 2;

int z = y +(y = 10);

printf("%d\n", z);

}

a)

12

b)

20

c)

Either 12 or 20

d)

4

9.

void main()

{

int a, b = 2, c;

a = 2 * (b++);

c = 2 * (++b);

}

a)

a = 4, c = 8

b)

a = 3, c = 8

c)

b = 3, c = 6

d)

a = 4, c = 6

10.

16>>2

a)

4

b)

8

c)

32

d)

64

11.

Output of an arithmetic expression with integers and real numbers is ___ by default.?

a)

Integer

b)

Real number

c)

Depends on the numbers used in the expression.

d)

None of the above

12.

int a = 10 + 4.867;

a)

a = 10

b)

a = 14.867

c)

a = 14

d)

compiler error.

13.

int a = 3.5 + 4.5;

a)

0

b)

7

c)

8

d)

8.0

14.

What is the other name for C Language ?: Question Mark Colon Operator.?

a)

Comparison Operator

b)

If-Else Operator

c)

Binary Operator

d)

Ternary Operator

15.

Expression x % y is equivalent to____?

a)

(x – (x/y))

b)

(x – (x/y) * y)

c)

(y – (x/y))

d)

(y – (x/y) * y)

16.

Which of the following is not a compound assignment operator?

a)

+=

b)

/=

c)

%=

d)

==

17.

What is the output of the following printf


printf("%d",34+24/12%3*5/2-4);

a)

35

b)

-2

c)

34

d)

38

18.

What is the output of the following code:

#include<stdio.h>

void main()

{

int a=10,b=80,c=45;

printf("%d",a<b>c);

}

a)

0

b)

1

c)

10

d)

Error

19.

What is the output of the following code:

#include<stdio.h>

void main()

{

int a=10,b=-5;

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

}

a)

1

b)

0

c)

Error

d)

10

e)

-5

20.

What is the output of the following printf


int a=9;

printf("%d",~a);

a)

10

b)

-10

c)

6

d)

-9

21.

What is the output of the following printf


int a=-11;

printf("%d",!a);

a)

0

b)

1

c)

12

d)

10

22.

What is the output of the following printf:


int a=6,b=8;

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

a)

14

b)

0

c)

6

d)

8

23.

Which of the following operators are related to short circuit

a)

Logical Operators

b)

Bitwise Operators

c)

Special Operators

d)

Increment/Decrement Operators

24.

What is the output of the following printf:


printf("%d",14%-4);

a)

2

b)

-2

c)

3

d)

0

25.

What is the output of the following printf:


int a=12,b=5,c=8;

printf("%d",a+=b-=c*=a-=10);

a)

-9

b)

122

c)

1

d)

-1

26.

What is the output of the following printf:


int a=10;

b=++a;

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

a)

11,11

b)

10,11

c)

11,10

d)

10,10

27.

What is the output of the following printf:


int a=1,2,3,4;

printf("%d",a);

a)

1

b)

2

c)

3

d)

4

e)

Compile time error

28.

What is the value of printf:


printf("%d",sizeof(double));

a)

8

b)

10

c)

4

d)

6

29.

What is the output of the following printf:


int a=10,b=3;

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

a)

80

b)

0

c)

20

d)

40

30.

What is the output of the following printf:


int a=20,b=15;

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

a)

31

b)

20

c)

1

d)

35

31.

What is the output of the following code snippet:


int a=12;

a?printf("GEC"):printf("IT");

a)

GEC

b)

IT

c)

GECIT

d)

Error

32.

Which of the following Arithmetic Operators are having highest priority

a)

/, *, %

b)

+, -

c)

Only * and /

d)

Only /

33.

What is the output of the following printf:


int a=10,b=8;

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

a)

1

b)

18

c)

19

d)

2

34.

What is the output of the following printf:


printf("%d",10<400>300>40);

a)

0

b)

1

c)

Error

d)

400

35.

Who developed the C programming language?

a)

Bjarne Stroustrup

b)

James Gosling

c)

Dennis Ritchie

d)

Ray Boyce

36.

A name having a few letters, numbers and special character _(underscore) is called

a)

keywords

b)

reserved keywords

c)

tokens

d)

identifiers

37.

The words if, else, auto, float etc. have predefined meaning and users cannot use them as variables.


These words are called

a)

keywords

b)

identifier

c)

data types

d)

constant

38.

Which is/are the integer constant/constants?

a)

Decimal integer constant

b)

Octal integer constant

c)

Hexadecimal integer constant

d)

All of the above

39.

Which operators perform operations on data in binary level?

a)

Logical operator

b)

Bitwise operator

c)

Additional opertors

d)

None of the above

40.

#include <stdio.h>

int main()

{

signed char chr;

chr = 128;

printf("%d\n", chr);

return 0;

}

a)

128

b)

0

c)

-128

d)

Garbage Value

41.

What will be the output of the following program?

#include <stdio.h>

int main()

{

float c = 5.0;

printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32);

return 0;

}

a)

Temperature in Fahrenheit is 41.00

b)

Temperature in Fahrenheit is 37.00

c)

Temperature in Fahrenheit is 0.00

d)

Compiler Error

42.

The format identifier ‘%i’ is also used for _____ data type.

a)

char

b)

int

c)

float

d)

double

43.

A single line comment line in a C Language source code can begin with

a)

;

b)

:

c)

//

d)

/*