wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DAY 7 Pointer Structure & Union - 18th June 2024

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a pointer in C programming?

a)

variable that stores the address of another variable

b)

A variable that stores multiple values

c)

A data type that can hold characters

d)

A function that returns a value

2.

How do you declare a pointer to an integer variable num in C?

a)

int ptr = #

b)

int *ptr = #

c)

ptr int = #

d)

int ptr = num;

3.

What is the output of the following C code snippet?

a)

10

b)

&num

c)

Compilation error

d)

Garbage value

4.

What is the value of ptr after the following lines of code?

a)

5

b)

&num

c)

Address of ptr

d)

Garbage value

5.

Which of the following operators is used to access the value pointed to by a pointer in C?

a)

&

b)

*

c)

%

d)

->

6.

What is the output of the following C code snippet?

a)

1

b)

2

c)

3

d)

4

7.

What is a structure in C programming?

a)

A way to organize multiple variables of the same type

b)

A way to store only integers

c)

A user-defined data type to store multiple variables of different types

d)

A way to declare arrays

8.

How do you declare a structure named Student with name (string) and age (integer) members in C?

a)

b)

c)

d)

9.

What is the correct way to access the age member of a structure variable stu in C?

a)

stu.age

b)

age.stu

c)

struct.stu.age

d)

age.struct.stu

10.

How do you declare a structure pointer in C to a structure Student?

a)

Student *ptr;

b)

struct *ptr = Student;

c)

struct Student *ptr;

d)

Student.ptr;

11.

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

a)

5 10

b)

10 5

c)

Compilation error

d)

Garbage values

12.

What is a union in C programming?

a)

A way to store multiple variables of different types in a single memory location

b)

A way to store multiple variables of the same type

c)

A user-defined data type to store only integers

d)

A way to declare arrays

13.

How do you declare a union named Number with integer and float members in C?

a)

b)

c)

d)

14.

What is the size of a union in C?

a)

Size of the largest member

b)

Size of the largest member

c)

Sum of sizes of all members

d)

Size of the first member

15.

How do you access the float member of a union variable num in C?

a)

num.float

b)

float.num

c)

union.num.float

d)

num->float