wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Programming in C – Quiz Questions

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

The name of an array in C represents:

a)

The last element address

b)

A variable

c)

The base address of the array

d)

The size of the array

2.

A string in C always ends with:

a)

\n

b)

EOF

c)

NULL

d)

\0

3.

Which operator is used to access the value pointed by a pointer?

a)

&

b)

*

c)

@

d)

->

4.

Bubble sort works by repeatedly:

a)

Selecting the minimum element

b)

Dividing the array

c)

Comparing adjacent elements and swapping

d)

Inserting elements at correct position

5.

Which of the following is the correct form of a function?

a)

function fun()

b)

def fun()

c)

void fun()

d)

fun():void

6.

Which arguments are passed to main()?

a)

arg and argv

b)

argc and argv

c)

args and argc

d)

argv and env

7.

What will be printed by the following recursive function?

int fun(int n)

{

if(n == 0)

return 0;

else

return n + fun(n-1);

}

int main()

{

printf("%d", fun(3));

}

a)

3

b)

5

c)

6

d)

9

8.

What will be the output of the following program? void fun(int *x) { *x = *x + 5; } int main() { int a = 10; fun(&a); printf("%d", a); }

a)

10

b)

15

c)

5

d)

Garbage value

9.

Which function is used to release dynamically allocated memory?

a)

malloc()

b)

calloc()

c)

realloc()

d)

free()

10.

A structure in C is used to:

a)

Store similar data types

b)

Store different data types together

c)

Increase execution speed

d)

Allocate dynamic memory

11.

Which operator is used to access structure members using pointer?

a)

.

b)

:

c)

*

d)

->

12.

In a union, memory allocated is equal to:

a)

Sum of all members

b)

Average of members

c)

Largest member

d)

Smallest member

13.

Bit-fields are used to:

a)

Speed up execution

b)

Store floating values

c)

Save memory

d)

Increase precision

14.

typedef is used to:

a)

Create new variables

b)

Rename existing data types

c)

Allocate memory

d)

Define constants

15.

Which function is used to release dynamically allocated memory?

a)

malloc()

b)

calloc()

c)

realloc()

d)

free()