Search Header Logo

DSA-Quiz1-Pointers

Authored by Anusha T

Information Technology (IT)

University

Used 1+ times

DSA-Quiz1-Pointers
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What is the primary purpose of a pointer in C?

To declare a new data type

To perform arithmetic operations on numbers

To store integer values

To store the memory address of another variable

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which operator is used to get the memory address of a variable?

. (dot operator)

& (address-of operator)

* (dereference operator)

-> (member access operator)

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

If `int *ptr;` is declared, what type of value can `ptr` store?

Address of a floating-point variable

An integer value

The memory address of an integer variable

A floating-point value

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What is the output of the following C code snippet?

int x = 10;

int p = &x;

printf("%d", *p);

The memory address of x

Error

Garbage value

10

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following statements correctly initializes a pointer `ptr` to point to an integer variable `num`?

ptr = *num;

int *ptr = #

int ptr = num;

int *ptr = num;

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What will be the value of `p` after the following operations and `int` takes 4 bytes?

int arr[] = {10, 20, 30, 40, 50}; int *p = arr; p = p + 2;

The address of `arr[2]`

The address of `arr[1]`

The value `30`

The address of `arr[0]` + 2 bytes

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

char str[] = "Hello"; char *ptr = str; What is the value of *(ptr + 2)?

The memory address of 'l'

e

H

l

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?