wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming MCQ

Total questions: 118

Worksheet time: 2hrs 42mins

Name
Class
Date
1.

Which one of the following languages is predecessor to C programming language?

a)

A.

b)

B.

c)

C++.

d)

Java.

2.

Which of the following symbol is used to denote a preprocessor statement?

a)

#

b)

;

c)

!

d)

~

3.

C is a/an __________ language.

a)

High –level

b)

Low - level

c)

Middle –level

d)

Assembly

4.

________ reserves all keywords C language

a)

Compiler

b)

Interpreter

c)

Header file

d)

None

5.

Which one of the statements is not valid with respect to low level language?

a)

Set of instructions in the form of sequences of zeros and ones.

b)

It is machine- dependent.

c)

It is confined to the configuration of the computer.

d)

It is easy to identify the commands of a low level language.

6.

A switch statement is used to ________

a)

Switch between function in a program.

b)

Switch form one variable to another variable.

c)

Choose from multiple possibilities which may arise due to different values of a single variable.

d)

Switching between variable and statements.

7.

A character array always ends with a/an ________.

a)

Null('\0') character

b)

Question mark(?)

c)

Full stop(.)

d)

Asterisk*

8.

Arrays cannot be initialized if they are (a)  

9.

Every C program must at least contain ______ function(s).

a)

Only one

b)

Only two

c)

Must contain one

d)

One or more

10.

Information will be passed to the function via special identifiers called _______.

a)

Argument

b)

Parameters

c)

Variable

d)

None

11.

Which of the following functions(s) return(s) multiple values?

a)

Printf()

b)

Scanf()

c)

Printf() & scanf()

d)

Fprintf()

12.

Explain the following pointer declaration int *p.

a)

P is a pointer

b)

p is a pointer to an integer quantity

c)

*p is a pointer

d)

*p is a pointer to an integer quantity

13.

C programs are converted into machine language with the help of

a)

An Editor

b)

A compiler

c)

An operating system

d)

None of these.

14.

C was primarily developed as

a)

System programming language

b)

General purpose language

c)

Data processing language

d)

None of the above.

15.

What will be the output of the following program? main() { system(" "); }

a)

control goes to the dos prompt.

b)

syntax error

c)

Bad command or file name

16.

What will be the output of the following program? main() { printf("\n%d%d%d%d",'A','B','C','D'); }

a)

ABCD.

b)

65666768.

c)

91929394.

d)

Error.

17.

which one of the following functions is appropriate for accepting a string?

a)

gets()

b)

getch()

c)

getche()

d)

scamf()

18.

preprocessor directives follow the following syntax rule_________.

a)

Begin with # and end with semi-colon.

b)

End with semi-colon.

c)

Begin with # and do not require a semi-colon.

d)

They must be include within<>

19.

consider the following code: #define M 5 total=*value; printf("M=%d\n",M); the two lines would be changed dring preprocessing as follows:

a)

total=M*value; printf("M=%d\n",M);

b)

total=5*value; printf("M=%d\n",M);

c)

total=5*value; printf("5=%d\n",M);

d)

total = 5*value; printf("M=%d\n",5)

20.

which of the following directives is equivalent to #ifdef

a)

#Ifdefine

b)

#Ifdefined()

c)

#Ifdef()

d)

#If

21.

Which one of the following is not a reserved keyword for C?

a)

auto

b)

case

c)

main

d)

default

22.

which one of the following statements is false with respect to the sequential

a)

The sequential files can grow or shrink dynamically.

b)

The records can be accessed sequentially.

c)

It has a fixed, predetermined number of components.

d)

It is a data structure which consists of the sequence of records of the same type and size.

23.

in “C” language it is assumed that input data appears as_______

a)

A stream.

b)

ASCII characters.

c)

bits.

d)

English alphabets.

24.

Which of the following is/are invalid variable(s)?

a)

interest paid

b)

si-int

c)

AVERAGE

d)

Both(b)and(d) of the above.

25.

Which one of the following C statement is not valid?

a)

int= 314.562*150

b)

si=principal*rateofinterest*number of years/100

c)

k=a*b+c(2.5a+b);

d)

None

26.

Which one of the following C statements represent the given formula? z= [8.8(a+b)2/c]/[0.5+2a/(q+r)] [ (a+b)*(1/m) ]

a)

z=((8.8(a+b)*2/c)-(.5+2*a/(q+r)))/a+b)

b)

z=((8.8*(a+b)*2/c)-(.5+2a/(q+r)))/a+b)

c)

z=((8.8*(a+b)*2/c)-(.5+2*a/(q+r)))/a+b)

d)

z=((8.8*(a+b)2/c)-(.5+2*a/(q+r)))/a+b)

27.

What will be the output of the following program? main() { int a=300,b,c; if (a>=400) b=300; c=200; printf("\n%d%d",b,c); }

a)

300,200

b)

error

c)

garbage value,garbage value

d)

garbage value,200

28.

What will be the output of the C code given below?

main()

{

int a=500,b,c;

if(a>=400)

b=300;

c=200;

printf(“\n%d%d”,b,c);

}

a)

error

b)

300,200

c)

garbage value,200

29.

Pick the choice which represents the output of the given code. main() { int j; while(j<=10) { printf("\n%d",j); j=j+1; } }

a)

Generates error

b)

Output cannot be predicted

c)

11

d)

1

30.

choose the right answer for the following code. main() { int i=1; while(i<=10); { printf("\n%d",i); i++; } }

a)

1

b)

2

c)

No output

d)

1,2,3,4,5,6,7,8,9,10

31.

Guess the output of the program given below .

main()

{

char x;

while(x=o;x<255;x++)

printf(“\nAscil value %d character%c”,x,x);

}

a)

The ASCII value of x is printed 255 times

b)

it indicates an error

c)

Indefinite output

d)

It indicates error since the same variable x cannot be initialized to 0 and x.

32.

each subscript in an array is________

a)

float

b)

integer

c)

any data type

d)

0

33.

How many elements does the array int a[5] contain?

a)

5

b)

6

c)

4

d)

7

34.

Which one of the following declares a one dimensional 30 element character array?

a)

char name[31]

b)

char name[30]

c)

char name[29]

d)

char name[]

35.

Which of the following is not a correct variable type?

a)

int

b)

real

c)

char

d)

double

36.

Write the C statement for the following C statement “a function called add accepts two integer arguments and returns a floating point value”

a)

float add (int,int)

b)

float add (int a, int b)

c)

float add ()

37.

Choose the meaning of the following statement given in C int(*pf)(char*a,char*b)

a)

pf is a function that accepts two characters as arguments and return and integer.

b)

pf is a function that accepts two characters as arguments and return and integer.

c)

pf is a pointer to a function that accepts two pointers to characters as arguments and returns an integer.

d)

pf is a pointer to a function that accepts two characters as arguments and returns an integer.

38.

& is a/an__________

a)

Binary operator.

b)

Unary operator.

c)

Conditional operator.

d)

Assignmen operator.

39.

The getchar () function reads a__________

a)

String from a file

b)

Character from a file

c)

String from the keyboard

d)

Character from the keyboard

40.

What is a preprocessor directive?

a)

It is a message from compiler to the programmer.

b)

It is a message from compiler to the linker.

c)

It is a message from programmer to preprocessor.

d)

It is a message from programmer to microprocessor.

41.

Which of the following holds (s) and advantage of using macros over functions?

a)

functions must have parameters; macros do no.

b)

The program is executed faster when a macro is used.

c)

Values passed to functions must be of a specific data type; values passed to macros do not.

d)

when macros are used many times in a program they are expanded each time.

42.

The C preprocessor is a collection of statements,called__________

a)

Directive

b)

Symbolic

c)

Include

d)

None

43.

Which of the statements is false with respect to structure and functions?

a)

The general format of sending a copy of a structure to the called function is function name(structure variable name)

b)

The called function must be declared for its type, appropriate to the data types it is expected to return.

c)

The structure variable used as the actual argument and the corresponding formal argument in the called function must be of the same struct type.

d)

when a function returns a structure, it is not necessary that it must be assigned to a structure of identical type in the calling function.

44.

The major distinction between the structure and unions is in terms of ________

a)

Storage

b)

Declaration of members

c)

Accessing the members

d)

Syntax

e)

Usage.

45.

The maximum length of a variable in C is__________

a)

8

b)

16

c)

32

d)

64

46.

The variable name can be started with__________

a)

Underscore symbol(_)

b)

Asterisk symbol(*)

c)

Ampere sand symbol(&)

d)

Numerals and characters.

47.

What is the result of 16>>2?

a)

4.

b)

8.

c)

2.

d)

5.

48.

A break statement is control structures is used__________

a)

To break the control from a switch statement

b)

To break the loop

c)

to continue a loop

d)

None

49.

Goto statement is__________

a)

Preferable for transferring the control to another part of the program.

b)

Preferable since it is easy to use

c)

Avoid as it can cause unpreferable transfer of control block within the program

d)

To continue with the next test condition of the loop

50.

Continue statement is control structures is used i

a)

For transferromg the control to another block of the program

b)

To exit out of the present loop

c)

To continue statement ends the current iteration of a loop

d)

None

51.

All the elements in the array must be__________

a)

Initialized.

b)

Defined.

c)

Numeric.

d)

None

52.

If you declare an array without stating the elements, it will be set to________

a)

A null value

b)

Zero

c)

A garbage value

d)

None

53.

Array are passed as arguments to a function by___________

a)

Value

b)

Reference

c)

Using pointers

d)

Both value and reference

54.

Which one of the statements is not valid

a)

The stract() function is used to concatenate the two string.

b)

The strcmp() function is used to compare the two string.

c)

strcpy() function determines the length of the string

d)

All correct

55.

Which of the following function(s) return(s) a value?

a)

voidf()

b)

voidf(int a, int b)

c)

f()

d)

float f(int a)

56.

In the normal function call there will be________ arguments(s) for each formal argument

a)

one actual

b)

Two actual

c)

One formal

d)

Three

57.

How many values are returned by a function?

a)

Function does not return any values.

b)

One

c)

Two

d)

Three

58.

A C program contains the following statements.

int j, j=20; int *pi, *pj=&j;

pj=j+5; i=pj+5;pi=pj; *pi=i+j;

The value assigned to I is______

a)

20

b)

30

c)

35

d)

15

59.

Suppose that x is a two dimensional integer array having 10 rows and 20 columns. The item in row 2 and column 5 can be accessed by:

a)

x[2][5]

b)

*((x+2)+5)

c)

*x+2,**x=5

d)

None

60.

'&' symbol

a)

Only (i) of the above

b)

Only (ii) of the above

c)

Only (iii) of the above

d)

None

61.

"%d" specifies

a)

Integer value to be read or printed

b)

Character values to be read or printed

c)

Double values to be read or printed

d)

String values to be read or printed

62.

Scan function is used to __________

a)

Reading values from the keyboard

b)

Initializing variables

c)

Printing the values to the console

d)

Accepting a string

63.

Which of the following is/are valid?

a)

A union may be member of a structure

b)

Structure and union may be freely mixed with arrays

c)

Union may be used in all place where structure is allowed.

d)

None

64.

To create variables of large size in C program, the following are used ________

a)

Structure

b)

Union

c)

Array

d)

Structure, unions and arrays

e)

Structure, unions.

65.

Which of the following statements is valid with respect to the bit field?

a)

Bit fields allow the packing of data in a structure.

b)

Bit fields can be of any data type, including float and double.

c)

Bit fields can have a size greater than the size of their base type.

d)

Bit fields can be accessed using pointers to their address.

66.

Which of the following is a valid way to declare a constant in C?

a)

const int x = 10;

b)

define x 10

c)

int const x = 10;

d)

Both (a) and (c)

67.

What will be the output of the following code? main() { int a = 5; int b = 10; printf("%d", a + b); }

a)

5,10

b)

15

c)

510

d)

Error

68.

Which of the following is not a valid loop structure in C?

a)

repeat-until

b)

for

c)

do-while

d)

while

69.

Which of the following is a header file in C?

a)

stdio.c

b)

conio.h

c)

main.h

d)

program.c

70.

The header file stdio.h mainly deals with:

a)

String manipulation

b)

Standard input/output

c)

Mathematical functions

d)

File handling only

71.

Which header file is required for mathematical functions like sqrt()?

a)

math.h

b)

stdio.h

c)

string.h

d)

conio.h

72.

Which of the following is a valid variable name in C?

a)

1number

b)

_value

c)

float

d)

long-int

73.

Which statement is true about identifiers?

a)

Identifiers can start with a number.

b)

Identifiers can contain spaces.

c)

Identifiers are case-sensitive.

d)

Keywords can be used as identifiers.

74.

Which of the following is an invalid variable declaration?

a)

int age;

b)

float marks;

c)

char name[20];

d)

double 2value;

75.

Which function is used for formatted output in C?

a)

printf()

b)

scanf()

c)

gets()

d)

puts()

76.

What is the correct format specifier for a float in printf()?

a)

%d

b)

%f

c)

%c

d)

%s

77.

Which function is used for reading a single character from user?

a)

scanf()

b)

getchar()

c)

gets()

d)

putchar()

78.

The ASCII value of character 'A' is:

a)

65

b)

97

c)

66

d)

64

79.

Which of the following ASCII values corresponds to a newline character \n?

a)

9

b)

10

c)

13

d)

32

80.

The ASCII value of digit '0' is:

a)

48

b)

49

c)

65

d)

97

81.

Which of the following is not a valid C data type?

a)

int

b)

float

c)

real

d)

double

82.

Which function is used to read a string from the user?

a)

scanf()

b)

printf()

c)

gets()

d)

putchar()

83.

Which operator is used to access the value at an address in C?

a)

&

b)

*

c)

->

d)

%

84.

What is the size of int data type in most 64-bit compilers?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

Depends on compiler

85.

What is the default return type of the main() function in C (modern compilers)?

a)

int

b)

void

c)

float

d)

char

86.

Which escape sequence represents a tab space?

a)

\t

b)

\n

c)

\r

d)

\b

87.

The ASCII value of lowercase 'a' is:

a)

65

b)

97

c)

66

d)

98

88.

Which symbol is used to denote a preprocessor directive in C?

a)

&

b)

$

c)

#

d)

@

89.

The C language was developed by:

a)

Bjarne Stroustrup

b)

Dennis Ritchie

c)

James Gosling

d)

Guido van Rossum

90.

Size of double in C (on most systems) is:

a)

1 byte

b)

2 bytes

c)

4 bytes

d)

8 bytes

91.

Which format specifier is used for a float with printf?

a)

%d

b)

%f

c)

%c

d)

%lf

92.

++i is known as:

a)

Post-increment

b)

Pre-increment

c)

Compound

d)

Decrement

93.

What is the value of 10 > 5 && 5 < 2?

a)

1

b)

0

c)

True

d)

Error

94.

Correct syntax of a switch?

a)

switch variable {case 1: … }

b)

switch(variable) { case 1: … }

c)

switch variable case1: …

d)

switch-case(variable) …

95.

For loop syntax is:

a)

for(init; condition; update)

b)

for(condition; init; update)

c)

for(init; update; condition)

d)

for(update; condition; init)

96.

Which keyword skips current iteration?

a)

stop

b)

skip

c)

continue

d)

next

97.

What is the output? #include int main() { int x=10; printf("%d", x*2); }

4 lines
98.

What is the output? #include int main() { int x=4; if(x%2==0) printf("Even"); else printf("Odd"); }

4 lines
99.

The C language was first developed in the year

a)

1969

b)

1972

c)

1980

d)

199

100.

The C-preprocessors are specified with _________ symbol.

a)

#

b)

$

c)

" "

d)

&

101.

Which is a valid relational operator?

a)

<>

b)

!=

c)

=

d)

:=

102.

Which loop executes at least once?

a)

for

b)

do…while

c)

while

d)

nested for

103.

Initialization, condition, and increment are used in

a)

while

b)

for

c)

do…while

d)

switch

104.

What is printed by for(i=0;i<3;i++) printf("%d",i);?

a)

0 1

b)

0 1 2

c)

1 2 3

d)

1 2

105.

Value of x? int x = 5; x *= 5;

a)

10

b)

15

c)

25

d)

7

106.

Output? #include int main() { int a=4; a*=2+3; printf("%d", a); }

4 lines
107.

Output? #include int main() { int i=3; while(i) { printf("%d", i); i--; } }

4 lines
108.

Output? #include int main() { int x=10; if(x>0) if(x<5) printf("Small"); else printf("Large"); }

4 lines
109.

Output? #include int main() { int x=5; if(x>5) printf("A"); else if(x==5) printf("B"); else printf("C"); }

4 lines
110.

Output? #include int main() { int x=5; printf("%d", x==5); }

4 lines
111.

Correct syntax to print “Hello”?

a)

printf(Hello);

b)

printf("Hello");

c)

print("Hello");

d)

cout<<"Hello";

112.

Correct ternary operator syntax?

a)

condition ? expr1 : expr2

b)

condition : expr1 ? expr2

c)

?condition:expr1:expr2

d)

if?expr1:expr2

113.

Correct while loop syntax?

a)

while (condition) { … }

b)

while condition { … }

c)

while: condition { … }

d)

do while(condition);

114.

Correct do–while syntax?

a)

do { … } while(condition);

b)

do while(condition) { … }

c)

do(condition) { … };

d)

whiledo { … };

115.

Choose the valid compound assignment statement:

a)

x =+ y;

b)

x += y;

c)

x = y+;

d)

x + y =;

116.

Which correctly checks if a is NOT equal to b?

a)

if(a =! b)

b)

if(a != b)

c)

if(a <> b)

d)

if(a =/= b)

117.

Proper way to use else-if ladder:

a)

if(cond1) … else if(cond2) … else …

b)

if(cond1) … elseif(cond2) … else …

c)

if(cond1) … else(cond2) …

d)

if(cond1, cond2) … else …

118.

Correct syntax for a for loop counting down from 10 to 1:

a)

for(i=10;i>=1;i--) { … }

b)

for(i=10;i>=1;i++) { … }

c)

for i=10 to 1 { … }

d)

for(i=10;i<=1;i--) { … }