wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Quiz

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.

Which of the following is not a valid variable name?

a)

_bca_90

b)

90_bca_

c)

bca29

d)

programmingLanguage_

2.

Which of the following functions reads multiple characters from the keyboard?

a)

getchar()

b)

getche()

c)

getch()

d)

gets()

3.

The statement used in C to branch unconditionally from one point to another:

a)

if

b)

if...else...

c)

goto

d)

switch

4.

Which of the following is an exit-controlled loop?

a)

while

b)

do...while

c)

for

d)

if

5.

Function header does not consist of:

a)

function type

b)

function name

c)

local variable declaration

d)

list of parameters

6.

In an array, subscript begins at:

a)

zero

b)

one

c)

n-1

d)

n

7.

When operator is placed before a pointer variable in an expression, it means:

a)

address of

b)

value at address

c)

address of pointer variable

d)

address of main

8.

The string function that compares two strings is:

a)

strlen()

b)

strcat()

c)

strcmp()

d)

strcomp()

9.

The function that reads an integer from a file is:

a)

putw()

b)

getw()

c)

fseek()

d)

ftell()

10.

Which of the following statements is not valid?

a)

C does not permit initialization of individual structure members within the template.

b)

Initialization must be done only in the declaration of the actual variables.

c)

The order of values enclosed in braces must match order of members in the structure definition.

d)

It is not permitted to have partial initialization.

11.

_____ are the names you supply for variables, types, functions and labels in your program.

a)

Constants

b)

Variables

c)

Identifiers

d)

Keywords

12.

Which header file can be used to define input/output function prototypes and macros?

a)

math.h

b)

memory.h

c)

stdio.h

d)

conio.h

13.

Storage size of type unsigned int is:

a)

1 byte

b)

2 bytes

c)

4 bytes

d)

8 bytes

14.

Which printf() statement will you use to print out a (float value) and b (double value)?

a)

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

b)

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

c)

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

d)

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

15.

The default parameter passing mechanism is:

a)

call by value

b)

call by reference

c)

call by value result

d)

call by function

16.

A recursive function is faster than _____ loop.

a)

for

b)

while

c)

do while

d)

None of the above

17.

How do you initialize an array in C?

a)

intarr[3] = (1,2,3);

b)

intarr(3) = {1,2,3};

c)

intarr[3] = {1,2,3};

d)

intarr(3) = (1,2,3);

18.

What is the value of an array element which is not initialized?

a)

By default zero 0

b)

1

c)

Depends on storage class

d)

None of the above

19.

FILE is of:

a)

int type

b)

char * type

c)

struct type

d)

None of the above

20.

C structure or user-defined data type is also called:

a)

derived data type

b)

secondary data type

c)

aggregate data type

d)

All of the above

21.

The C programming language was originally developed by:

a)

Ken Thompson

b)

Dennis M. Ritchie

c)

Brian Kernighan

d)

Mark Zuckerberg

22.

The C programming language is:

a)

high-level language

b)

assembly language

c)

machine language

d)

scripting language

23.

What will be the output for the following code? #include int main( ) { int a = 5, b = 5; printf("%d", a+++--b); return 0; }

a)

10

b)

9

c)

8

d)

7

24.

What will be the output for the following code? #include int main( ) { int a = 0; while( )a = 0 { printf("a d= % ", a); } return 0; }

a)

a = 0

b)

0

c)

No output

d)

Syntax error

25.

The return type void returns:

a)

integer

b)

float

c)

character

d)

nothing

26.

Any C program:

a)

must contain at least one function

b)

needs not contain any function

c)

needs input data

d)

None of the above

27.

What is the right way to initialize an array?

a)

int num[] = {6, 2, 4, 12, 5, 45};

b)

int n = {2, 4, 12, 5, 45, 5};

c)

int n[6] = {2, 4, 12};

d)

int n() = {6, 2, 4, 12, 5, 45};

28.

What is the meaning of the following code about pointers? int *ptr, p;

a)

ptr is a pointer to integer, p is not

b)

ptr and p, both are pointers to integer

c)

ptr is pointer to integer, p may or may not be

d)

ptr and p both are not pointer to integer

29.

Select a function which is used to write a string to a file:

a)

puts()

b)

putc()

c)

fputs()

d)

fgets()

30.

What is a structure in C language?

a)

A structure is a collection of elements that can be of same data type

b)

A structure is a collection of elements that can be of different data types

c)

Elements of a structure are called members

d)

All of the above

31.

What is the right way to initialize an array?

a)

int num[6] = {2, 4, 12, 5, 45, 5};

b)

int n{ } = {2, 4, 12, 5, 45, 5};

c)

int n{6} = {2, 4, 12};

d)

int n{6} = {2, 4, 12, 5, 45, 5};

32.

The symbol || is used to represent logical:

a)

AND

b)

OR

c)

NOT

d)

NAND

33.

The ?: operator is known as:

a)

arithmetic

b)

conditional

c)

binary

d)

loop

34.

o represent logical:

a)

AND

b)

OR

c)

NOT

d)

NAND

35.

The ?: operator is known as:

a)

arithmetic

b)

conditional

c)

binary

d)

loop

36.

The field specification for reading an integer number is:

a)

%c

b)

%f

c)

%1f

d)

%d

37.

What will be the result of 9 % 2 in a C program?

a)

0

b)

1

c)

2

d)

4

38.

What is the output of the following code? int main() { int x = 10; { int x = 0; printf("%d", x); } return 0; }

a)

10

b)

Compilation error

c)

0

d)

Undefined

39.

Which of the following is the correct syntax to send an array as a parameter to a function?

a)

func(&array);

b)

func(#array);

c)

func(*array);

d)

func(array[size]);

40.

What is the output of the following program? #include int main() { char c; FILE *fp; fp = fopen("demo.txt", "r"); while((c = fgetc(fp)) != EOF) printf("%c", c); fclose(fp); return 0; }

a)

It will print the content till newline

b)

It will print the content of file demo.txt

c)

Compilation error

d)

Undefined

41.

A pointer is:

a)

a keyword used to create variables

b)

a variable that stores the address of another variable

c)

a variable that stores the address of an instruction

d)

All of the above

42.

The size of a union is determined by the size of the:

a)

first member in the union

b)

last member in the union

c)

biggest member in the union

d)

sum of the sizes of all members

43.

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

a)

int number;

b)

float rate;

c)

int variable_count;

d)

int main#;

44.

Which of the following declarations is not supported by C language?

a)

String str;

b)

char *str;

c)

float str = 3e2;

d)

int a[2] [2];

45.

Which of the following is an example of iteration in C?

a)

for

b)

while

c)

do-while

d)

All of the above

46.

How many times i value is checked in the following C program?

#include<stdio.h> int main(void) { int i=0;  while(i<3) i++; printf("In while loop\n"); }

a)

2

b)

3

c)

4

d)

1

47.

void main() { int x = 5 * 9 / 3 + 9; }

a)

3.75

b)

4.09

c)

24

d)

3

48.

Which keyword can be used to come out of recursion?

a)

break

b)

return

c)

exit

d)

Both break and return

49.

What are the elements present in the array of the following C code? Int array[5] = {5};

a)

5, 5, 5, 5, 5

b)

5, (garbage), (garbage), (garbage), (garbage)

c)

5, 0, 0, 0, 0

d)

(garbage), (garbage), (garbage), (garbage), 5

50.

Which of the following is an indirection operator?

a)

&

b)

*

c)

->

d)

.

51.

Which of the following are themselves a collection of different data types?

a)

string

b)

structures

c)

char

d)

array

52.

What is meant by 'a' in the following C operation? fp = fopen("Random.txt", "a");

a)

Attach

b)

Append

c)

Apprehend

d)

Add

53.

How many main () functions can we have in any program?

a)

1

b)

2

c)

No limit

d)

Depends on compiler

54.

What will be the data type of the result of the following operation? (float)a* (int) b / (long) c * (double) d

a)

int

b)

long

c)

float

d)

double

55.

A user-defined data type, which is used to assign names to integral constants is called

a)

union

b)

structure

c)

array

d)

enum

56.

What is the output? int main () { int n; for (n=9; n>=0; n--) printf ("n=%d", n--); return (); }

a)

9 7 5 3 1

b)

9 8 7 6 5 4 3 2 1

c)

infinite loop

d)

9 7 5 3

57.

What is the output of the following? int main () { int x=10; { int x=0; printf ("%d", x); } return 0; }

a)

10

b)

Compilation error

c)

0

d)

Undefined

58.

Value of static storage variable

a)

changes during different function calls

b)

persists between different function calls

c)

increase during different function calls

d)

decrease during different function calls

59.

Which of the following is the correct syntax to send an array as a parameter to the function?

a)

func (*array)

b)

func (array[size])

c)

func (&array)

d)

func (array)

60.

Which of the following is correct about the program?

a)

j is a pointer to an int and stores the address of i

b)

j and i are pointers to an int

c)

i is a pointer to an int and stores the address of j

d)

j is a pointer to a pointer to an int and stores the address of i

61.

Which of the following operations is illegal in a structure?

a)

Pointer to a variable of the same structure

b)

Dynamic allocation of memory for structure

c)

Typecasting of structure

d)

Both (a) and (b)

62.

Choose the right statement for fscanf() and scanf():

a)

fscanf() can read from standard input whereas scanf() specifies a stream from which to read()

b)

fscanf() can specify a stream from which to read whereas scanf() can read only from standard input

c)

fscanf() and scanf() have no difference in their functions

d)

fscanf() and scanf() can read from the specified stream