wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PrelimExam-ComOrg-FCPC

Total questions: 50

Worksheet time: 50mins

Name
Class
Date
1.

In assembly, the .data section is used for:

a)

Program instructions

b)

Uninitialized variables

c)

Initialized variables

d)

Comments

2.

The .bss section is used for:

a)

Initialized variables

b)

Uninitialized variables

c)

Instructions

d)

Comments

3.

The .text section is used for:

a)

Instructions/code

b)

Data values

c)

Stack storage

d)

Comments

4.

Which section stores constants defined before the program runs?

a)

.bss

b)

.data

c)

.text

d)

Stack

5.

Which section stores uninitialized variables that will be set later?

a)

.bss

b)

.data

c)

.text

d)

Heap

6.

Which section contains executable machine code?

a)

.data

b)

.bss

c)

.text

d)

Stack

7.

The .data section usually takes space in:

a)

Source file only

b)

Executable file and memory

c)

Nowhere

d)

Only registers

8.

A variable declared in .bss is initialized to:

a)

Zero

b)

One

c)

Random value

d)

NULL pointer

9.

Which of the following is TRUE about .text section?

a)

It is read-only in many systems

b)

It is writable by default

c)

It stores uninitialized variables

d)

It stores stack data

10.

If you want a variable to start with value 10, you put it in:

a)

.bss

b)

.data

c)

.text

d)

Stack

11.

If you want a variable without an initial value, you put it in:

a)

.bss

b)

.data

c)

.text

d)

Registers

12.

The .bss section is usually:

a)

Large, for static storage

b)

Read-only

c)

Removed after compilation

d)

Empty always

13.

In .text, labels usually represent:

a)

Instructions or addresses in code

b)

Variable values

c)

Comments

d)

None

14.

.data and .bss together store:

a)

Program code

b)

Program variables

c)

Stack frames

d)

Constants only

15.

A string like "Hello" is stored in:

a)

.bss

b)

.data

c)

.text (read-only data)

d)

Heap

16.

If you declare resb 10 in assembly, memory is reserved in:

a)

.data

b)

.bss

c)

.text

d)

Registers

17.

The .data section variables:

a)

Must always be zero

b)

Have initial values

c)

Cannot be accessed by code

d)

Disappear after compile

18.

The .text section starts with the label:

a)

main:

b)

_start:

c)

data:

d)

entry:

19.

If you want code to run, it must be in:

a)

.data

b)

.text

c)

.bss

d)

.stack

20.

The .bss section saves memory because:

a)

It is not stored in executable file, only reserved at runtime

b)

It is duplicated in .text

c)

It uses registers only

d)

It is deleted automatically

21.

In C, the operator & is used to:

a)

Get the value of variable

b)

Get the address of variable

c)

Multiply

d)

Add

22.

In C, the operator * is used to:

a)

Multiply

b)

Get the value stored at an address (dereference)

c)

Find address

d)

Comment

23.

If int x=5;, then &x gives:

a)

5

b)

Address of x

c)

Garbage

d)

0

24.

In C, a pointer is a variable that stores:

a)

A number

b)

An address of another variable

c)

Only zero

d)

Nothing

25.

If int x=7; int *p=&x;, then *p is:

a)

Address of x

b)

Value of x

c)

Random number

d)

NULL

26.

A null pointer is written as:

a)

&0

b)

0

c)

-1

d)

1

27.

Printing a pointer with %p shows:

a)

Value of variable

b)

Address stored in pointer

c)

ASCII code

d)

Error

28.

If int arr[3] = {1,2,3};, then arr refers to:

a)

Last element

b)

Address of first element

c)

Array size

d)

Random value

29.

Which function allocates memory dynamically?

a)

malloc()

b)

free()

c)

sizeof()

d)

printf()

30.

Which function frees memory?

a)

free()

b)

malloc()

c)

calloc()

d)

realloc()

31.

An uninitialized pointer contains:

a)

0

b)

Garbage address

c)

NULL

d)

-1

32.

A pointer to an int is declared as:

a)

int p;

b)

int *p;

c)

pointer int p;

d)

int &p;

33.

If int *p=NULL;, dereferencing *p causes:

a)

0

b)

Error (crash)

c)

Garbage

d)

Address of p

34.

A pointer pointing to another pointer is called:

a)

Wild pointer

b)

Double pointer

c)

Constant pointer

d)

Dangling pointer

35.

If int arr[4]={10,20,30,40}; int *p=arr;, then *(p+2) is:

a)

10

b)

20

c)

30

d)

40

36.

The default value of a pointer if not initialized is:

a)

0

b)

Garbage address

c)

NULL

d)

Address of main()

37.

Accessing memory outside an array gives:

a)

Error always

b)

Undefined behavior

c)

Zero

d)

Garbage safely

38.

A pointer that is freed but still used is called:

a)

Null pointer

b)

Dangling pointer

c)

Constant pointer

d)

Void pointer

39.

A pointer that can point to any data type is:

a)

Double pointer

b)

Void pointer

c)

Constant pointer

d)

Null pointer

40.

If int x=10; int *p=&x;, then printf("%d", *p); prints:

a)

10

b)

Address of x

c)

Random

d)

Error

41.

Pointer arithmetic moves by:

a)

Always 1 byte

b)

Size of the type pointed to

c)

Random step

d)

2 bytes always

42.

If char *p;, pointer arithmetic moves by:

a)

1 byte

b)

2 bytes

c)

4 bytes

d)

8 bytes

43.

If int *p; on a 64-bit machine, then p+1 moves by:

a)

1 byte

b)

2 bytes

c)

4 bytes

d)

8 bytes

44.

The sizeof(pointer) on a 64-bit system is usually:

a)

2

b)

4

c)

8

d)

16

45.

If int x=5; int *p=&x; int **q=&p;, then **q is:

a)

Address of p

b)

Address of x

c)

Value of x (5)

d)

Garbage

46.

A wild pointer is:

a)

Always NULL

b)

Declared but not initialized

c)

A pointer to another pointer

d)

A constant pointer

47.

The function calloc() in C:

a)

Allocates memory uninitialized

b)

Allocates zero-initialized memory

c)

Frees memory

d)

Prints memory

48.

The function realloc() is used to:

a)

Allocate memory once

b)

Resize previously allocated memory

c)

Free memory

d)

Initialize arrays

49.

If int *p; and p=&x;, then *p gives:

a)

Address of x

b)

Value of x

c)

Garbage

d)

NULL

50.

Good practice is to initialize a pointer to:

a)

Zero (NULL)

b)

Random address

c)

Value of another variable

d)

Ignore it