wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

Which of the following cannot be a variable name in C?

a)

volatile

b)

true

c)

friend

d)

export

2.

Which of the following declaration is not supported by C?

a)

String str;

b)

char *str;

c)

float str = 3e2;

d)

both String str; & float str = 3e2;

3.

Which keyword is used to prevent any changes in the variable within a C program?

a)

immutable

b)

mutable

c)

const

d)

volatile

4.

What is the result of logical or relational expression in C?

a)

True or False

b)

0 or 1

c)

0 if an expression is false and any positive number if an expression is true

d)

none of the mentioned

5.

What is the Format specifier used to print a Character array in C Printf or Scanf function?

a)

%c

b)

%C

c)

%s

d)

%d

6.

What is the output of C Program with Strings?

a)

globy

b)

globy\0

c)

compiler error

d)

‘g’ ‘l’ ‘o’ ‘b’ ‘y’

7.

How do you convert this char array to string?

char str[]={'g','l','o','b','y'};

a)

str[5] = 0;

b)

str[5] = '\0'

c)

str[]={'g','l','o','b','y','\0'};

d)

All of the above

8.

What is the output of the following program?

a)

30

b)

20

c)

compile time error

d)

run time error

9.

In C a pointer variable to an integer can be created by the declaration

a)

int p*;

b)

int *p;

c)

int +p;

d)

int $p;

10.

Will this program compile ?

a)

Yes

b)

No

11.

Which function is used to delete the allocated memory space ?

a)

Dealloc()

b)

free()

c)

Both a and b

d)

None of the above

12.

malloc() allocates memory from the heap and not from the stack.

a)

TRUE

b)

FALSE

c)

May Be

d)

Can't Say

13.

What is the output of C Program with switch statement ?

a)

ANT KING PALACE

b)

KING PALACE

c)

ANT PALACE

d)

Compiler error for using expressions

14.

What is the output of C Program with switch statement or block ?

a)

BOAT CHILLY

b)

BOAT PETROL CHILLY

c)

SHIP BOAT CHILLY

d)

Compiler error

15.

What is right way to Initialize 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 };

16.

What will be the output of the program ?

a)

3,2,15

b)

2,3,20

c)

2,1,15

d)

1,2,5

17.

An array elements are always stored in ________ memory location.

a)

SEQUENTIAL

b)

RANDOM

c)

SEQUENTIAL AND RANDOM

d)

NONE OF THE ABOVE

18.

Let x be an array. Which of the following operations are illegal?

I. ++x

II. x+1

III. x++

IV. x*2

a)

I and II

b)

I,II and III

c)

II and III

d)

I,III and IV

e)

III and IV

19.

What is the maximun number of dimensions an array in C may have?

a)

Two

b)

eight

c)

sixteen

d)

Theoratically no limit. The only practical limits are memory size and compilers

20.

Array is an example of _______ type memory allocation.

a)

Compile time

b)

Run time

c)

Both A and B

d)

None of the above

21.

Size of the array need not be specified, when

a)

Initialization is a part of definition

b)

It is a formal parameter

c)

It is a declaratrion

d)

All of the above

22.

The following code is an example of?

double da = 4.5;

double db = 4.6;

double dc = 4.9;

int result = (int)da + (int)db + (int)dc;

printf(""result = %d"", result);

a)

Implicit Type Conversion

b)

Explicit Type Conversion

c)

Error

d)

Cannot say

23.

The data structure used to implement recursive function calls _____________.

a)

Array

b)

Linked List

c)

Binary tree

d)

Stack

24.

What will be output for the following code?

a)

Hello is printed once

b)

Hello will be printed infinite number of times

c)

Hello is not printed at all

d)

0 is returned

25.

OUTPUT OF THE PROGRAM

a)

5Good Morning

b)

M

c)

Good

d)

Morning

e)

None of the above

26.

What does the following declaration mean?

int (*ptr)[10];

a)

ptr is array of pointers to 10 integers

b)

ptr is a pointer to array of 10 integers

c)

ptr is an array of 10 integers

d)

ptr is a pointer to array

27.

What will be the output of the following C code?

a)

0

b)

1

c)

Compile time error

d)

Undefined behaviour

28.

What will be the output of the following C code?

a)

i,am

b)

iam

c)

i am

d)

error

29.

The______function returns a pointer to the first character of a token.

a)

strstr()

b)

strcpy()

c)

strspn()

d)

strtok()

30.

What is the output of the following code ?

a)

6

b)

9

c)

12

d)

8

31.

What does this declaration mean?

int x : 4; 

a)

X is a four-digit integer.

b)

X cannot be greater than a four-digit integer.

c)

X is a four-bit integer.

d)

None of the these

32.

How many times will the following loop execute?

for(j = 1; j <= 10; j = j-1) 

a)

Forever

b)

Never

c)

0

d)

1

33.

What is the result after execution of the following code if a is 10, b is 5, and c is 10?

a)

a = 10, c = 10

b)

a = 11, c = 10

c)

a = 10, c = 11

d)

a = 11, c = 11

34.

What will happen if the following C code is executed?

a)

It will cause a compile-time error

b)

It will cause a run-time error

c)

It will run without any error and prints 3

d)

It will experience infinite looping

35.

What will be the final value of x in the following C code?

a)

3.75

b)

Depends on compiler

c)

24

d)

3

36.

What will be the output of the following C code? (Initial values: x= 7, y = 8)

a)

7.000000, 7

b)

Run time error

c)

7.000000, junk

d)

Varies

37.

What will be the output of the following C code snippet?

a)

returns 1

b)

returns 2

c)

varies

d)

compile time error

38.

What will be the data type returned for the following C function?

a)

char

b)

int

c)

double

d)

multiple type-casting in return is illegal

39.

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, 0, 0, 0, 0

c)

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

d)

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

40.

Which keyword is used to come out of a loop only for that iteration?

a)

break

b)

continue

c)

return

d)

none of the mentioned above