NEW
Font size
WorksheetsPrelimExam-ComOrg-FCPC
Total questions: 50
Worksheet time: 50mins
In assembly, the .data section is used for:
Program instructions
Uninitialized variables
Initialized variables
Comments
The .bss section is used for:
Initialized variables
Uninitialized variables
Instructions
Comments
The .text section is used for:
Instructions/code
Data values
Stack storage
Comments
Which section stores constants defined before the program runs?
.bss
.data
.text
Stack
Which section stores uninitialized variables that will be set later?
.bss
.data
.text
Heap
Which section contains executable machine code?
.data
.bss
.text
Stack
The .data section usually takes space in:
Source file only
Executable file and memory
Nowhere
Only registers
A variable declared in .bss is initialized to:
Zero
One
Random value
NULL pointer
Which of the following is TRUE about .text section?
It is read-only in many systems
It is writable by default
It stores uninitialized variables
It stores stack data
If you want a variable to start with value 10, you put it in:
.bss
.data
.text
Stack
If you want a variable without an initial value, you put it in:
.bss
.data
.text
Registers
The .bss section is usually:
Large, for static storage
Read-only
Removed after compilation
Empty always
In .text, labels usually represent:
Instructions or addresses in code
Variable values
Comments
None
.data and .bss together store:
Program code
Program variables
Stack frames
Constants only
A string like "Hello" is stored in:
.bss
.data
.text (read-only data)
Heap
If you declare resb 10 in assembly, memory is reserved in:
.data
.bss
.text
Registers
The .data section variables:
Must always be zero
Have initial values
Cannot be accessed by code
Disappear after compile
The .text section starts with the label:
main:
_start:
data:
entry:
If you want code to run, it must be in:
.data
.text
.bss
.stack
The .bss section saves memory because:
It is not stored in executable file, only reserved at runtime
It is duplicated in .text
It uses registers only
It is deleted automatically
In C, the operator & is used to:
Get the value of variable
Get the address of variable
Multiply
Add
In C, the operator * is used to:
Multiply
Get the value stored at an address (dereference)
Find address
Comment
If int x=5;, then &x gives:
5
Address of x
Garbage
0
In C, a pointer is a variable that stores:
A number
An address of another variable
Only zero
Nothing
If int x=7; int *p=&x;, then *p is:
Address of x
Value of x
Random number
NULL
A null pointer is written as:
&0
0
-1
1
Printing a pointer with %p shows:
Value of variable
Address stored in pointer
ASCII code
Error
If int arr[3] = {1,2,3};, then arr refers to:
Last element
Address of first element
Array size
Random value
Which function allocates memory dynamically?
malloc()
free()
sizeof()
printf()
Which function frees memory?
free()
malloc()
calloc()
realloc()
An uninitialized pointer contains:
0
Garbage address
NULL
-1
A pointer to an int is declared as:
int p;
int *p;
pointer int p;
int &p;
If int *p=NULL;, dereferencing *p causes:
0
Error (crash)
Garbage
Address of p
A pointer pointing to another pointer is called:
Wild pointer
Double pointer
Constant pointer
Dangling pointer
If int arr[4]={10,20,30,40}; int *p=arr;, then *(p+2) is:
10
20
30
40
The default value of a pointer if not initialized is:
0
Garbage address
NULL
Address of main()
Accessing memory outside an array gives:
Error always
Undefined behavior
Zero
Garbage safely
A pointer that is freed but still used is called:
Null pointer
Dangling pointer
Constant pointer
Void pointer
A pointer that can point to any data type is:
Double pointer
Void pointer
Constant pointer
Null pointer
If int x=10; int *p=&x;, then printf("%d", *p); prints:
10
Address of x
Random
Error
Pointer arithmetic moves by:
Always 1 byte
Size of the type pointed to
Random step
2 bytes always
If char *p;, pointer arithmetic moves by:
1 byte
2 bytes
4 bytes
8 bytes
If int *p; on a 64-bit machine, then p+1 moves by:
1 byte
2 bytes
4 bytes
8 bytes
The sizeof(pointer) on a 64-bit system is usually:
2
4
8
16
If int x=5; int *p=&x; int **q=&p;, then **q is:
Address of p
Address of x
Value of x (5)
Garbage
A wild pointer is:
Always NULL
Declared but not initialized
A pointer to another pointer
A constant pointer
The function calloc() in C:
Allocates memory uninitialized
Allocates zero-initialized memory
Frees memory
Prints memory
The function realloc() is used to:
Allocate memory once
Resize previously allocated memory
Free memory
Initialize arrays
If int *p; and p=&x;, then *p gives:
Address of x
Value of x
Garbage
NULL
Good practice is to initialize a pointer to:
Zero (NULL)
Random address
Value of another variable
Ignore it
