wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming Concepts Worksheet

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.

What is the output of sizeof(int) on a 64-bit system?

a)

2

b)

4

c)

8

d)

Depends on compiler

2.

What will happen if free() is called twice on the same pointer?

a)

Memory leak

b)

Undefined behavior

c)

Segmentation fault always

d)

Program runs normally

3.

Which of the following is NOT a valid storage class?

a)

auto

b)

static

c)

register

d)

dynamic

4.

Which operator cannot be overloaded in C?

a)

+

b)

*

c)

=

d)

None (C does not support operator overloading)

5.

Which of the following can cause a segmentation fault?

a)

Dereferencing NULL

b)

Dereferencing uninitialized pointer

c)

Accessing freed memory

d)

All of these

6.

What is the return type of malloc()?

a)

int

b)

void*

c)

char*

d)

float*

7.

Which function moves the file pointer relative to current position?

a)

rewind()

b)

fseek()

c)

ftell()

d)

fmove()

8.

Which macro checks if a file has reached end-of-file?

a)

file_end()

b)

end()

c)

feof()

d)

eof()

9.

What is the output of: printf("%d", 10 << 1);

a)

5

b)

10

c)

20

d)

40

10.

What is the purpose of the restrict keyword?

a)

Makes variable constant

b)

Helps compiler optimize pointer access

c)

Prevents pointer arithmetic

d)

Allocates memory dynamically

11.

What happens if main() has no return statement in C?

a)

Compiler error

b)

Undefined behavior

c)

Returns 0 implicitly

d)

Program crash

12.

What is the output of strcmp("ABC", "ABD")?

a)

0

b)

1

c)

Negative value

d)

Positive value

13.

Which symbol is used to end a statement in C?

a)

A) :

b)

B) ;

c)

C) .

d)

D) ,

14.

Which data type stores a single character?

a)

int

b)

char

c)

float

d)

double

15.

Which function is used to print output?

a)

input()

b)

print()

c)

printf()

d)

scan()

16.

Which header file is required for printf()?

a)

math.h

b)

stdio.h

c)

string.h

d)

conio.h

17.

Which operator is used for division?

a)

/

b)

%

c)

*

d)

//

18.

Which keyword is used to declare a constant?

a)

final

b)

constant

c)

const

d)

static

19.

Which data type stores decimal values?

a)

int

b)

float

c)

char

d)

short

20.

What does the sizeof operator do?

a)

Calculates time

b)

Converts data type

c)

Gives memory size

d)

Prints size on screen

21.

What is the default return type of a function if not specified?

a)

void

b)

int

c)

float

d)

depends on compiler

22.

What is the correct syntax to input an integer x?

a)

scanf("%d", x);

b)

scanf("%d", &x);

c)

scanf("%i", x);

d)

read("%d", &x);

23.

Which escape sequence prints a new line?

a)

\t

b)

\n

c)

\s

d)

\\

24.

In an if condition, which value is treated as false?

a)

1

b)

0

c)

Any non-zero value

d)

None

25.

What is the scope of a variable declared inside a function?

a)

Global

b)

Block (local)

c)

Static

d)

File

26.

Which keyword returns control from a function?

a)

goto

b)

exit

c)

return

d)

break

27.

What happens if a function is called before it is declared?

a)

Compiler error

b)

Linker error

c)

Implicit declaration (deprecated)

d)

Function executes normally

28.

What is the purpose of main() in C?

a)
Optional
b)

Program execution starts here

c)

Stores all variable declarations

d)

Calls functions only

29.

Which of the following correctly represents a character constant?

a)

“A”

b)

‘A’

c)

A

d)

(A)

30.

What is the output of strcmp(“Hello”, “Hello”)?

a)

0

b)

1

c)

-1

d)

Undefined