wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming

Total questions: 100

Worksheet time: 2hrs 43mins

Name
Class
Date
1.

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

a)

1

b)

2

c)

No Limit

d)

None

2.

How many loop are there in C

a)

2

b)

3

c)

1

d)

4

3.

When is C Language was invented

a)

1970

b)

1972

c)

1978

d)

1979

4.

Library function getch() belongs to which header file?

a)

stdio.h

b)

conio.h

c)

stdlib.h

d)

none

5.

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

6.

What are Parameter passing techniques available in C Language

a)

Call by value

b)

Call by reference

c)

Both

d)

None

7.

Array is collection of elements of

a)

Dis-similarity Data Types

b)

Similar Data Types

c)

Both

d)

None

8.

structures are collection of elements of

a)

Dis-similarity Data Types

b)

Similar Data Types

c)

Both

d)

None

9.

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

10.

Arithmetic operators available in C Language are

a)

+ , -, *, / , %

b)

+ , -, *, / , <

c)

+ , -, *, ==, <=

d)

&&, ||, ==, >=

11.

Pointer variable is to hold

a)

int value

b)

float value

c)

Address

d)

None

12.

Examples of unconditional statements

a)

goto , continue

b)

goto, continue, break

c)

break, continue

d)

goto break

13.

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

14.

Program execution starts from

a)

#include

b)

main()

c)

Other sub-functions

d)

None

15.

Conditional operator (? :) is a

a)

Unary Operator

b)

Binary Operator

c)

Ternary Operator

d)

All

16.

Examples for Unary operators

a)

% , /

b)

==, &&

c)

<= , >=

d)

++ , --

17.

What is output for:

a=5;

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

a)

5

b)

6

c)

4

d)

0

18.

What is the Output:

int a=5;

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

a)

5

b)

6

c)

7

d)

4

19.

What is the output:

int i;

printf("%d", i);

a)

0

b)

Garbage value

c)

1

d)

Error

20.

What is the Output:

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

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

a)

17

b)

22

c)

11

d)

Error

21.

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

22.

what is the output:

void main()

{

int a=5;

a+=2;

printf("%d",a);

}

a)

7

b)

5

c)

6

d)

Error

23.

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

24.

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

25.

What is the technique name for the following Function call swap():

void main()

{

swap(3,7)

}

a)

Call by value

b)

Call by reference

c)

Both

d)

None

26.

What is the Keyword used to define a Structure

a)

Structure

b)

Static

c)

Dynamic

d)

Struct

27.

which of the following is Address operator

a)

&&

b)

&

c)

||

d)

==

28.

"goto" statement is:

a)

Conditional statement

b)

Assignment statement

c)

Declaration statement

d)

Unconditional statement

29.

Which of the following is a Unary Operator

a)

&&

b)

||

c)

<

d)

!

30.

C language was developed by

a)

B. Stroustrup

b)

James Gosling

c)

Anders Hejlsberg

d)

Dennis M.Ritchie

31.
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
32.
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)
33.
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
34.
Point out the error in the following program 
a)
No error
b)
display() doesn't get invoked
c)
display() is called before it is defined
d)
None of these
35.
Point out the error in the following program
a)
Error: Declaration syntax error 'v' (or) Size of v is unknown or zero.
b)
Program terminates abnormally.
c)
No error
d)
None of these.
36.
In which order do the following gets evaluated
1.Relational
2.Arithmetic
3.Logical
4.Assignment
a)
2134
b)
1234
c)
4321
d)
3214
37.
The keyword used to transfer control from a function back to the calling function is
a)
switch
b)
goto
c)
go back
d)
return
38.
What will be the output of the program?
a)
Hello
b)
Hi Hello
c)
No output
d)
Infinite loop
39.
What is (void*)0?
a)
Representation of NULL pointer
b)
Representation of void pointer
c)
Error
d)
None of above
40.
Point out the compile time error in the program given below.
a)
Error: invalid assignment for x
b)
Error: suspicious pointer conversion
c)
No error
d)
None of above
41.
If the two strings are identical, then strcmp() function returns
a)
-1
b)
1
c)
0
d)
yes
42.
How will you print \n on the screen?
a)
printf("\n");
b)
echo "\\n";
c)
printf('\n');
d)
printf("\\n");
43.
In which numbering system can the binary number 1011011111000101 be easily converted to?
a)
Decimal system
b)
Hexadecimal system
c)
Octal system
d)
None Of The Above
44.
What will be the output of the program?
a)
128
b)
Garbage value
c)
Error
d)
0
45.
In C, if you pass an array as an argument to a function, what actually gets passed?
a)
Value of elements in array
b)
First element of the array
c)
Base address of the array
d)
Address of the last element of array
46.
What is the similarity between a structure, union and enumeration?
a)
All of them let you define new values
b)
All of them let you define new data types
c)
All of them let you define new pointers
d)
All of them let you define new structures
47.
What function should be used to free the memory allocated by calloc() ?
a)
dealloc();
b)
malloc(variable_name, 0)
c)
free();
d)
memalloc(variable_name, 0)
48.
Which of the following function is used to find the first occurrence of a given string in another string?
a)
strchr()
b)
strrchr()
c)
strstr()
d)
strnset()
49.
Which statement will you add in the following program to work it correctly?
a)
#include<conio.h>
b)
#include<math.h>
c)
#include<stdlib.h>
d)
#include<dos.h>
50.
We want to round off x, a float, to an int value, The correct way to do is
a)
y = (int)(x + 0.5)
b)
y = int(x + 0.5)
c)
y = (int)x + 0.5
d)
y = (int)((int)x + 0.5)
51.
Associativity has no role to play unless the precedence of operator is same.
a)
True
b)
False
52.
Functions cannot return more than one value at a time
a)
True
b)
False
53.
In C all functions except main() can be called recursively.
a)
True
b)
False
54.
The modulus operator cannot be used with a long double.
a)
True
b)
False
55.
A preprocessor directive is a message from programmer to the pre-processor.
a)
True
b)
False
56.

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

57.

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

58.

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

59.

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

60.

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

61.

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

62.

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

63.

Find Error/ output in following code

int main ()

{

int x = 1;

While (x= 0)

printf (" Hello");

}

a)

Hello

b)

No output

c)

Infinite time Hello display

d)

Error in code

64.

Find Error/ output in following code

int main ()

{

int x= 0, y= 0;

if ( x > 0)

if ( y >0)

printf ("True");

else

printf ("False");

}

a)

No output

b)

True

c)

False

d)

Error because of dangling else problem

65.

Find Error/ output in following code

Void main ()

{

int a= 1, b= 2, c = 3;

Char d = 0;

if (a,b,c,d)

{

printf ( " EXAM") ;

}

}

a)

No output and No error

b)

EXAM

c)

Runtime Error

d)

Compile time error

66.

Find Error/ output in following code

Void main ()

{

printf ( " % d " , printf ( " computer science"));

}

a)

Computer science16

b)

16computer science

c)

Computer science

d)

Computer science18

67.

What will be the output of the program?

int main ()

{

printf ( 5+"Good Morning\n");

return 0;

}

a)

Good Morning

b)

Good

c)

M

d)

Morning

68.

Are the expression *ptr++ and ++*ptr are the same ?

a)

True

b)

False

69.

Is there any difference between the following two statements?

Char *p = 0;

Char *t = NULL ;

a)

Yes

b)

No

70.

Point out the error in the program

f ( int a, int b)

{

int a;

a = 20;

return a;

}

a)

Missing parentheses in return statement

b)

The function should be defined as int f ( int a, int b)

c)

Redeclaration of a

d)

None of the above

71.

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

72.

int main()


{


char arr[7]="Network";


printf("%s", arr);


return 0;


}

a)

Network

b)

N

c)

Garbage Value

d)

Compilation error

73.

#include<stdio.h>

int main()

{

char arr[11]="The African Queen";

printf("%s",arr);

}

a)

The African Queen

b)

The

c)

The African

d)

Compilation error

74.

#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

75.

int main ()


{


int x = 24, y = 39, z = 45;


z = x + y;


y = z - y;


x = z - y;


printf ("n%d %d %d", x, y, z);


}

a)

24 39 63

b)

39 24 63

c)

24 39 45

d)

39 24 45

76.

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

77.

int main() {


int x = 0, y = 0;


if(x > 0)


if(y > 0)


printf("True");


else


printf("False");


}

a)

No Output

b)

True

c)

False

d)

Error because of dangling else problem

78.

int main()


{


int a = 1, b=2, c=3;


char d = 0;


if(a,b,c,d)


{


printf("EXAM");


}


}

a)

No Output and No Error

b)

EXAM

c)

Run time error

d)

Compile time error

79.

#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

80.

What will be output of the following c program?

#include<stdio.h>

int main()

{

int max-val=100;

int min-val=10;

int avg-val;

avg-val = max-val + min-val / 2;

printf("%d",avg-val);

}

a)

55

b)

105

c)

60

d)

Compilation error

81.

There are ___ storage classes in C

a)

2

b)

4

c)

6

d)

8

82.

The data type int uses ___ bytes of memory.

a)

2

b)

4

c)

6

d)

8

83.

To show end of program ___ symbol used?

a)

<

b)

(

c)

{

d)

}

84.

Which is the incorrect form of variable?

a)

sale20

b)

Name

c)

12Rno

d)

Net_Salary

85.

What is the default C Storage Class for a variable?

a)

static

b)

auto

c)

register

d)

extern

86.

When variable declare as “ a++  “ it increment variable by ___ value.

a)

0

b)

1

c)

2

d)

3

87.

To find reminder _____ operator is use in C program

a)

%

b)

@

c)

/

d)

|

88.

By using  _____ function we can clear output window in C program

a)

clear()

b)

clrscr()

c)

screenclear()

d)

clean()

89.

C program is save with _____ extension.

a)

.a

b)

.b

c)

.c

d)

.d

90.

Using if  else statement we can check _____ condition.

a)

1

b)

2

c)

3

d)

4

91.

Switch statement checks only _____ condition.

a)

Equality

b)

Not equal to

c)

Less than

d)

Greater than

92.

Which one of following is not a reserved keyword in C?

a)

auto

b)

main

c)

case

d)

default

93.

The printf() & scanf() function come from _____ header file.

a)

conio.h

b)

stdio.h

c)

math.c

d)

getio.h

94.

Each statement in C program is end with _____ symbols.

a)

:

b)

,

c)

/

d)

;

95.

Static Storage class has _____ initial value.

a)

0

b)

1

c)

2

d)

3

96.

There are _____ keywords in C.

a)

30

b)

31

c)

32

d)

33

97.

Which statement is incorrect about Identifier?

a)

They can contain alphabets, digits & underscore only

b)

The identifier is made up of 31 character.

c)

They can use keyword.

d)

The first character must be an alphabet & underscore.

98.

To print multiple character _____ formatting character use.

a)

%d

b)

%f

c)

%s

d)

%c

99.

By using “ \n ” escape sequence the output is display in_____.

a)

New Line

b)

1st Line

c)

Middle Line

d)

End Line

100.

A identifier must be begin with_____

a)

Alphabets

b)

Digits

c)

Underscore or digits

d)

Alphabets or Underscore