wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming

Total questions: 70

Worksheet time: 39mins

Name
Class
Date
1.

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

2.

#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

3.

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

4.

#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

5.

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

6.

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

7.

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

8.

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

9.

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.

10.

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

11.

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

12.

Choose correct C while loop syntax.

a)

while(condition) { //statements }

b)

{ //statements }while(condition)

c)

while(condition); { //statements }

d)

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

13.

Choose a correct C for loop syntax.

a)

for(initalization; condition; incrementoperation) { //statements }

b)

for(declaration; condition; incrementoperation) { //statements }

c)

for(declaration; incrementoperation; condition) { //statements }

d)

for(initalization; condition; incrementoperation;) { //statements }

14.

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.

15.

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.

16.

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

17.
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
a)
rem = 3.14 % 2.1;
b)
rem = modf(3.14, 2.1);
c)
rem = fmod(3.14, 2.1);
d)
Remainder cannot be obtain in floating point division
18.
Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others.
a)
Yes
b)
No
19.
In which order do the following gets evaluated
1.Relational
2.Arithmetic
3.Logical
4.Assignment
a)
2134
b)
1234
c)
4321
d)
3214
20.
The keyword used to transfer control from a function back to the calling function is
a)
switch
b)
goto
c)
go back
d)
return
21.
The modulus operator cannot be used with a long double.
a)
True
b)
False
22.

Every C Program Statement must be terminated with a

a)

.

b)

#

c)

;

d)

!

23.

What does the following code fragment write to the monitor?

a)

Under

b)

Over

c)

Under the limit

d)

Over the limit

24.

What does the following code fragment write to the monitor?

a)

Under

b)

Over

c)

Under the limit

d)

Over the limit

25.

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

26.

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

27.

The operator "&" is used for

a)

Bitwise AND

b)

Bitwise OR

c)

Logical AND

d)

Logical OR

28.

The operator "&" is used for

a)

Bitwise AND

b)

Bitwise OR

c)

Logical AND

d)

Logical OR

29.

The size of a character variable in C is

a)

8 bytes

b)

4 bytes

c)

2 bytes

d)

1 byte

30.

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

31.

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

32.

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

33.

Which operators perform operations on data in binary level?

a)

Logical operator

b)

Bitwise operator

c)

Additional opertors

d)

None of the above

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

What is the value of this expression using integer arithmetic:

7 / 4

a)

1

b)

2

c)

1.75

36.

Determine the value of this expression using integer arithmetic:

5 % 7

a)

0

b)

2

c)

5

37.

Determine the value of b in this code fragment:

int a=3, b;

b=++a;

a)

3

b)

4

c)

2

38.

Determine the value of the expression using integer arithmetic:

6 * 9 % 3 / 2

a)

2

b)

0

c)

18

39.

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

40.

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);

41.

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

42.

What symbol is used in conditional operators for AND:

a)

AND

b)

&&

c)

&

43.

What will be printed on the screen from this fragment:

int num=0;

printf("%d", ++num)

a)

0

b)

1

c)

2

44.

What is the abbreviated way to write this assignment statement:

total=total+num;

a)

t=t+n;

b)

total+=num

c)

total=(total+num)

45.

C language is a

a)

structured program

b)

object oriented program

c)

oriented program

d)

basic program

46.

Relational operator

a)

+

b)

=

c)

==

d)

/

47.

a=2;b=6; (a<b):10:15

a)

10

b)

15

c)

2

d)

6

48.

After first pass the answer for x=5-6/3+8*2-1

a)

5-2+8*2-1

b)

5-6/3+16-1

c)

5-2+16-1

d)

-1/3+8*2-1

49.

%s indicates in scanf statement

a)

to get an integer

b)

to get a character

c)

to get a string

d)

to get a real no.

50.

What is the data type use for whole number?

a)

%ld

b)

%f

c)

%lf

51.

What operator that will be perform last in a given equation?

a)

+

b)

/

c)

%

52.

What format specifier is use for double data type?

a)

%lf

b)

%d

c)

%f

53.
What is an interpreter?
a)
Converts source code one instruction at a time
b)
Converts source code between 2 HLLs
c)
Converts source code between HLL and Assembly
d)
Converts keyboard presses to an ASCII code
54.
What would you use to convert high-level source code to machine code?
a)
Linker
b)
Assembler
c)
Compiler
d)
IDE
55.

Which should be the printf statement of the following program:

void main()

{

int age = 10;

printf...

}

a)

printf("I am %d years old.\n");

b)

printf("I am %f years old.\n", age);

c)

printf("I am %s years old.\n");

d)

printf("I am %d years old.\n", age);

56.

Check the following code segment and try to predict what's going to happen?

#include <stdio.h>

int main(){

int x=++2;

printf("%d",x);

return 0;

}

a)

3 will be printed on compilation and execution.

b)

2 will be printed on compilation and execution.

c)

compilation error - "Ivalue required".

d)

runtime error.

57.

Libray function getch() belongs to which header file?

a)

stdio.h

b)

conio.h

c)

stdlib.h

d)

stdlibio.h

58.

What is the value of X in the sample code given below?

X = ( 2 + 3) * 2 + 3;

a)

10

b)

13

c)

25

d)

28

59.

What value will be stored in z if the following code is executed?

x = 5 , y = -10, a = 4, b = 2;

z = x+++++y * b/a;

a)

-2

b)

0

c)

1

d)

2

60.

#include <stdio.h>

void main()

{

int k = 8;

int x = 0 == 1 && k++;

printf(“%d%d\n”, x, k);

}

a)

a) 0 9

b)

b) 0 8

c)

c) 1 9

d)

d) 1 8

61.

#include <stdio.h>

int main()

{

int x = 2, y = 2;

x /= x / y;

printf(“%d\n”, x);

return 0;

}

a)

a) 2

b)

b) 0.5

c)

c) 1

d)

d) Undefined behaviour shown

62.

#include <stdio.h>

int main()

{

int x = 2, y = 1;

x *= x + y;

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

return 0;

}

a)

a) 6

b)

b)5

c)

c) Undefined behavior shown

d)

d) Compilation time error

63.

#include<stdio.h>

void main()

{

int a=5;

int b=6;

a++;

b++;

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

}

a)

5 6

b)

6 7

c)

5 7

d)

Compilation Error

64.

#include<stdio.h>

int main()

{

int x;

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

{

if(x < 5)

continue;

else

break;

printf("SKCT");

}

return 0;

}

a)

A.Infinite times

b)

B. 11 times

c)

C. 0 times

d)

D.10 times

65.

#include<stdio.h>

int main()

{

int i=0;

for(; i<=5; i++);

printf("%d", i);

return 0;

}

a)

Compilation Error

b)

6

c)

012345

d)

12345

66.

#include<stdio.h>

int main()

{

float a = 0.7;

if(0.7 > a)

printf("Hi\n");

else

printf("Hello\n");

return 0;

}

a)

A.Hi

b)

B. Hello

c)

C. Hi Hello

d)

D.None of above

67.

#include<stdio.h>

int main()

{

int k, num = 30;

k = (num < 10) ? 100 : 200;

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

return 0;

}

a)

A.200

b)

B. 30

c)

C. 100

d)

D.500

68.

#include<stdio.h>

int main()

{

int a = 300, b, c;

if(a >= 400)

b = 300;

c = 200;

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

return 0;

}

a)

A.300, 300, 200

b)

B. Garbage, 300, 200

c)

C. 300, Garbage, 200

d)

D.300, 300, Garbage

69.

#include<stdio.h>

int main()

{

char j=1;

while(j < 5)

{

printf("%d, ", j);

j = j+1;

}

printf("\n");

return 0;

}

a)

1 2 3 ... 127

b)

1 2 3 ... 255

c)

1 2 3 ... 127 128 0 1 2 3 ... infinite times

d)

1, 2, 3, 4

70.

The modulus operator cannot be used with a long double.

a)

True

b)

False