wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Unit 1

Total questions: 100

Worksheet time: 50mins

Name
Class
Date
1.
How would you round off a value from 1.66 to 2.0?
a)
ceil(1.66)
b)
floor(1.66)
c)
roundup(1.66)
d)
roundto(1.66)
2.

Which of the following is not a valid variable name declaration?

a)

int a3;

b)

int 3a;

c)

int _A3;

d)

int a_3

3.

All keywords in C are in ____________

a)

Lowercase

b)

Uppercase

c)

Camelcase

d)

None of these

4.

A translator which reads an entire program written in a high level language and converts it into machine language code is:

a)

Assembler

b)

Compiler

c)

Linker

d)

Loader

5.

Which is correct with respect to size of the data types?

a)

char > int > float

b)

int > char > float

c)

char < int < double

d)

double > char > int

6.

Which is valid C variable declarations?

a)

int my_num = 100,000;

b)

int my_num = 100000;

c)

int my num = 1000;

d)

int $my_num = 10000;

7.

The functions printf() and scanf() are defined in which of the following library file:-

a)

math.h

b)

conio.h

c)

stdio.h

d)

stdlib.h

8.

#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

9.

#include <stdio.h>

void main()

{

int k = 4;

float k = 4;

printf("%d", k)

}

A.

a)

4

b)

4.000000

c)

No output

d)

Compile time Error

10.

Who developed C language

a)

Dennis Ritchie

b)

Bill Gates

c)

Dennis Lilly

d)

Stephen

11.

Which is variable declaration?

a)

int a,b;

b)

c=a+b;

c)

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

d)

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

12.

how to print a and b variable of int and float respectively

a)

scanf("%d%f",&a,&b);

b)

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

c)

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

d)

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

13.

Choose all the correct statements in reference to the programming language C

a)

General purpose programming language

b)

Middle level programming language

c)

Structured programming language

d)

Object oriented programming language

14.

Library function pow() belongs to which header file?

a)

mathio.h

b)

math.h

c)

square.h

d)

stdio.h

15.

Libray function getch() belongs to which header file?

a)

stdio.h

b)

conio.h

c)

stdlib.h

d)

stdlibio.h

16.

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

a)

keywords

b)

reserved keywords

c)

tokens

d)

identifiers

17.

What will be the output of the C code?

a)

Hello World! x;

b)

Hello World! followed by a junk value

c)

Compile time error

d)

Hello World!

18.

Is it possible to run program without main() function?

a)

yes

b)

no

c)

-

d)

-

19.

Which of the following is not a correct variable type?

a)

float

b)

real

c)

int

d)

char

20.
What punctuation is used to indicate the beginning and end of code blocks?
a)
{ }
b)
-> <-
c)
BEGIN and END
d)
( and )
21.

Evaluate(to true or false) each of the following expressions:

(1) 14 <= 14

(2) 14 < 14

a)

false false

b)

true true

c)

true false

d)

false true

22.

Which of the following is the boolean operator for logical-AND?

a)

&

b)

&&

c)

|

d)

||

23.

What is the output of C Program.?

int main()

{

int a=5;

while(a >= 3);

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed infinite times

d)

None of the above

24.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{

printf("%d ", a);

a++;

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

25.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}

while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

26.

Choose a correct C Statement.

a)

a++ is (a=a+1) POST INCREMENT Operator

b)

a-- is (a=a-1) POST DECREMENT Operator

--a is (a=a-1) PRE DECREMENT Operator

c)

++a is (a=a+1) PRE INCREMENT Operator

d)

All the above.

27.

Choose correct Syntax for C Arithmetic Compound Assignment Operators.

a)

a+=b is (a= a+ b)

a-=b is (a= a-b)

b)

a*=b is (a=a*b)

a/=b is (a = a/b)

c)

a%=b is (a=a%b)

d)

All the above.

28.

In the following loop construct, which one is executed only once always.

for(exp1; exp2; exp3)

a)

exp1

b)

exp3

c)

exp1 and exp3

d)

exp1,exp2 and exp3

29.

The continue statment cannot be used with

a)

for

b)

while

c)

do while

d)

switch

30.

int main()


{


int a = 10, b = 25;


a = b++ + a++;


b = ++b + ++a;


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


}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

31.

#include<stdio.h>

int main()

{

float a=0.7;

if(a<0.7)

{

printf("C");

}

else

{

printf("C++");

}

}

a)

C

b)

C++

c)

Compilation Error

d)

None of the these

32.

int main() {


int m = -10, n = 20;


n = (m < 0) ? 0 : 1;


printf("%d %d", m, n);


}

a)

-10 0

b)

10 20

c)

20 -10

d)

0 1

33.

#include<stdio.h>

int main()

{

int a=2,b=7,c=10;

c=a==b;

printf("%d",c);

}

a)

0

b)

7

c)

2

d)

Compilation error

34.

What is the output of C Program.?

int main()

{

int a=5;

while(a >= 3);

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed infinite times

d)

None of the above

35.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

if(a > 35)

break;

}

while(1);

return 0;

}

a)

No Output

b)

32 33 34

c)

32 33 34 35

d)

Compiler error

36.

What is the output of C Program.?

int main()

{

int k;

for(;;)

{

printf("TESTING\n");

break;

}

return 0;

}

a)

No Output

b)

TESTING

c)

Compiler error

d)

None of the above

37.

What is the way to suddenly come out of or Quit any Loop in C Language.?

a)

continue; statement

b)

break; statement

c)

leave; statement

d)

quit; statement

38.

Choose correct C while loop syntax.

a)

while(condition) { //statements }

b)

{ //statements }while(condition)

c)

while(condition); { //statements }

d)

while() { if(condition) { //statements } }

39.

What is the output of C Program.?

int main()

{

int a=5;

while(a==5)

{

printf("RABBIT");

break;

}

return 0;

}

a)

RABBIT is printed unlimited number of times

b)

RABBIT

c)

Compiler error

d)

None of the above.

40.

What is the output of C Program.?

int main()

{

int a=5;

while(a=123)

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed unlimited number of times.

d)

Compiler error.

41.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int i = 0;

do {

i++;

printf("In while loop\n");

} while (i < 3);

}

a)

In while loop

In while loop

In while loop

b)

In while loop

In while loop

c)

Depends on the compiler

d)

Compile time error

42.
In which order do the following gets evaluated
1.Relational
2.Arithmetic
3.Logical
4.Assignment
a)
2134
b)
1234
c)
4321
d)
3214
43.
The modulus operator cannot be used with a long double.
a)
True
b)
False
44.

Every C Program Statement must be terminated with a

a)

.

b)

#

c)

;

d)

!

45.

What does the following code fragment write to the monitor?

a)

Under

b)

Over

c)

Under the limit

d)

Over the limit

46.

When applied to a variable, what does the unary "&" operator yield?

a)

The variable's address

b)

The variable's right value

c)

The variable's binary form

d)

The variable's value

47.

The operator "&" is used for

a)

Bitwise AND

b)

Bitwise OR

c)

Logical AND

d)

Logical OR

48.

The size of a character variable in C is

a)

8 bytes

b)

4 bytes

c)

2 bytes

d)

1 byte

49.

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

50.

Which operators are used to compare the values of operands to produce logical value in C language

a)

Logical operator

b)

Relational operator

c)

Assignment operator

d)

None of the above

51.

An opertor used to check a condition and select a value depending on the value of the condition is called

a)

Logical operator

b)

Decrement operator

c)

Conditional or Ternary operator

d)

Bitwise operator

52.
How will you print \n on the screen?
a)
printf("\n");
b)
echo "\\n";
c)
printf('\n');
d)
printf("\\n");
53.

Which operators perform operations on data in binary level?

a)

Logical operator

b)

Bitwise operator

c)

Additional opertors

d)

None of the above

54.

What is the value of this expression using integer arithmetic:

7 / 4

a)

1

b)

2

c)

1.75

55.

Determine the value of this expression using integer arithmetic:

5 % 7

a)

0

b)

2

c)

5

56.

Determine the value of b in this code fragment:

int a=3, b;

b=++a;

a)

3

b)

4

c)

2

57.

Determine the value of the expression using integer arithmetic:

6 * 9 % 3 / 2

a)

2

b)

0

c)

18

58.

Determine the value of a in the second line of the code fragment:

int a=1, b=2;

a=b--;

a)

1

b)

0

c)

2

59.

Which line of code is correct for the statement:

Read in a value for the integer variable num.

a)

printf("%d", &num);

b)

scanf("%d", num);

c)

scanf("%d", &num);

60.

What is the EXACT output from this code fragment:

int num=10;

if(num> 7 % 3 / 2 * 3)

printf("This is True");

else

printf("This is False");

a)

This is True

b)

This is False

61.

Find the output in following code

int main ()

{

int a,b ;

a= b= 4 ;

b =a++;

Printf ( " %d %d %d %d", a++, --b, ++a, b--);

}

a)

5 3 73

b)

5 4 5 3

c)

6 2 6 4

d)

Syntax Error

62.

Find error/ output in following code

int main ()

{

Static int num = 8;

printf ( " %d" , num = num -2 );

if (num != 0)

main ();

}

a)

8 6 4 2

b)

Infinite output

c)

Invalid because main function can't call it self

d)

6 4 2 0

63.

Find error/ output in following code

How many times " placement Questions" will print.

int main

{

int x;

for ( x=1;x <=10; x++)

{

if ( x < 5)

Continue;

else

break;

Printf (" placement Question ");

{

return 0;

}

a)

Infinite time

b)

11 times

c)

0 time

d)

10 times

64.

Find error/ output in following code

int main ()

{

int a = 10, b = 25;

a = b++ + a++;

b= ++b + ++a;

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

}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

65.

Find error/ output in following code

Void fn ()

{

Static int i= 10;

Printf ( " %d " , ++i );

}

int main ()

{

fn();

fn();

}

a)

10 10

b)

11 12

c)

11 11

d)

12 12

66.

Find error/output in following code

int main ()

{

int m = -10,n =20;

n = ( m < 0) ? 0 : 1;

printf ( " %d %d ", m,n ) ;

}

a)

-10 0

b)

10 20

c)

20 -10

d)

0 1

67.

Find error/ output in following code

int main ()

{

int i = 0;

for ( ; ;)

printf ( "%d", i) ;

return 0;

}

a)

O times

b)

Infinite times

c)

10 times

d)

1 times

68.

How many main() function we can have in a program

a)

1

b)

2

c)

No Limit

d)

None

69.

How many loop are there in C

a)

2

b)

3

c)

1

d)

4

70.

which of the following ways can be used to include header file in C program

a)

#include"stdio.h"

b)

#include<stdio.h>

c)

both

d)

none

71.

what are the basic data types in C Language

a)

int , float

b)

int , float , char

c)

int, float, char , double

d)

int, char, double

72.

Arithmetic operators available in C Language are

a)

+ , -, *, / , %

b)

+ , -, *, / , <

c)

+ , -, *, ==, <=

d)

&&, ||, ==, >=

73.

Conditional statements are

a)

Simple if , if-else , else-if, switch

b)

Simple if , if-else , else-if, while

c)

Simple if , do-while , else-if, switch

d)

Simple if , if-else , do-while , for

74.

Program execution starts from

a)

#include

b)

main()

c)

Other sub-functions

d)

None

75.

Conditional operator (? :) is a

a)

Unary Operator

b)

Binary Operator

c)

Ternary Operator

d)

All

76.

Examples for Unary operators

a)

% , /

b)

==, &&

c)

<= , >=

d)

++ , --

77.

What is output for:

a=5;

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

a)

5

b)

6

c)

4

d)

0

78.

What is the output:

int i;

printf("%d", i);

a)

0

b)

Garbage value

c)

1

d)

Error

79.

What is the Output:

int a=5,b=6,c=2;

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

a)

17

b)

22

c)

11

d)

Error

80.

What is the Output :

void main()

{

int a=5,b=6,k;

k=b>a?b:a;

printf("%d",k);

}

a)

5

b)

6

c)

11

d)

Error

81.

What is the Output:

void main()

{

int a=4, b=2,c;

c=a*b;

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

}

a)

4, 2, 8

b)

2, 4, 8

c)

4, 8, 2

d)

2, 8, 4

82.

what is the Output:

void main()

{

int a=3,b=6;

if(a>b)

printf("%d",a);

else

printf("%d",b);

}

a)

3

b)

6

c)

Compilation Error

d)

Run Time Error

83.

"goto" statement is:

a)

Conditional statement

b)

Assignment statement

c)

Declaration statement

d)

Unconditional statement

84.

What is the output of C Program.?

int main()

{

while(true)

{

printf("RABBIT");

break;

}

return 0;

}

a)

RABBIT

b)

RABBIT is printed unlimited number of times.

c)

No output

d)

Compiler error.

85.

Correct printf statement to print “Hello world”

a)

printf("Hello world);

b)

print("Hello World");

c)

printf(Hello world");

d)

printf("Hello World");

86.

how to Read value from the user into the variable a of type int.

a)

scanf("Read value",&a)

b)

scanf("%d,a");

c)

scanf("%d",&a);

d)

scanf("%d",a);

87.

Which one is not a correct identifier name

a)

num1

b)

num_1

c)

_num1

d)

num 1

88.

How to read multiple values from user for the integer variables a,b and c in a single line?

a)

scanf("%d %d %d",a,b,c);

b)

scanf("%d %d %d,a,b,c);

c)

scanf("%d %d %d",&a,&b,&c");

d)

scanf("%d %d %d",&a,&b,&c);

89.

which is correct to define constants in c program

a)

const int 3.14

b)

const pi-3.14

c)

#define int PI 3.14

d)

const float PI=3.14

90.

A block of comments begin and ends with

a)

starting with / and ending with //

b)

starting with /* and ending with */

c)

starting with // and ending with //

d)

staring with < and ending with >

91.

For assignment statement

a)

Left value should be a variable always

b)

right value can be constant, variable, an expression or combination of this

c)

the assignment is always take place from right to left and never the other way

d)

all of above

92.

Which of the following is not a valid expression in c

a)

a=2+(b=5);

b)

a=b=c=5;

c)

a=11%3

d)

b+5=3;

93.

Which operator has the lowest priority

a)

++

b)

||

c)

+

d)

%

94.

Which of the following is not a valid relational operator

a)

==

b)

=>

c)

<=

d)

>=

95.

which statement uses valid escape sequence:

a)

printf(“Enter two numbers”/n)

b)

printf(“Enter two numbers”\n);

c)

printf(“Enter two numbers/n”);

d)

printf(“Enter Two number\n”);

96.

x<<7 means

a)

x is assigned value 7

b)

x is shifted to right by 7 bytes

c)

x is shifted to left by 7 bits

d)

x is shifted to right by 7 bits

97.

Which is incorrect?

a)

rem=3%2

b)

rem=3.14%2.

c)

rem=’a’%’c’

d)

none of the above

98.

what is result of 16>>2

a)

1

b)

8

c)

2

d)

4

99.

int a=29, b=10;

float c;

c=(float)(a/b)

a)

2.9

b)

2

c)

3

d)

compile dependent

100.

which is the valid variable declaration

a)

int temp salary;

b)

float marks_student;

c)

float roll-no;

d)

int main;