Showing posts with label Pointers. Show all posts
Showing posts with label Pointers. Show all posts

Consider the code snippet below. int ch = 100; Which of the following is a legally correct way of obtaining the memory location of ch and printing it (the memory location) to standard output, based on the given code snippet?

Consider the code snippet below.
int ch = 100;
Which of the following is a legally correct way of obtaining the memory location of ch and printing it (the memory location) to standard output, based on the given code snippet?


A) cout << ch << endl;
B) cout << *ch << endl;
C) cout << &ch << endl;
D) cout << *(&ch) << endl;

Ans: C
Title: Which statement gets the memory location of ch and prints it to standard output?
Difficulty: Easy

What is true about the statement given below? int* choice;

What is true about the statement given below?
int* choice;


A) choice is an integer variable
B) choice contains the memory location of an integer variable
C) choice can store two memory addresses simultaneously
D) choice can also store a string value

Ans: B
Title:  What is true about (variable declaration)?
Difficulty: Easy

Which of the following statements is true about pointers?

Which of the following statements is true about pointers?


A) Pointers contain values as well as addresses of variables.
B) Pointers contain address locations of variables.
C) Pointers do not have any address location of their own.
D) Pointers occupy permanent storage locations inside the hard disk.

Ans: B
Title: Which statement is true about pointers?
Difficulty: Medium