NEW
Font size
WorksheetsDAY 7 Pointer Structure & Union - 18th June 2024
Total questions: 15
Worksheet time: 8mins
What is a pointer in C programming?
variable that stores the address of another variable
A variable that stores multiple values
A data type that can hold characters
A function that returns a value
How do you declare a pointer to an integer variable num in C?
int ptr = #
int *ptr = #
ptr int = #
int ptr = num;
What is the output of the following C code snippet?
10
&num
Compilation error
Garbage value
What is the value of ptr after the following lines of code?
5
&num
Address of ptr
Garbage value
Which of the following operators is used to access the value pointed to by a pointer in C?
&
*
%
->
What is the output of the following C code snippet?
1
2
3
4
What is a structure in C programming?
A way to organize multiple variables of the same type
A way to store only integers
A user-defined data type to store multiple variables of different types
A way to declare arrays
How do you declare a structure named Student with name (string) and age (integer) members in C?
What is the correct way to access the age member of a structure variable stu in C?
stu.age
age.stu
struct.stu.age
age.struct.stu
How do you declare a structure pointer in C to a structure Student?
Student *ptr;
struct *ptr = Student;
struct Student *ptr;
Student.ptr;
What will be the output of the following C code snippet?
5 10
10 5
Compilation error
Garbage values
What is a union in C programming?
A way to store multiple variables of different types in a single memory location
A way to store multiple variables of the same type
A user-defined data type to store only integers
A way to declare arrays
How do you declare a union named Number with integer and float members in C?
What is the size of a union in C?
Size of the largest member
Size of the largest member
Sum of sizes of all members
Size of the first member
How do you access the float member of a union variable num in C?
num.float
float.num
union.num.float
num->float
