0% found this document useful (0 votes)
57 views2 pages

C++ Assignments - Pointers - Week 4

The document contains C++ assignments focused on pointers for Week 4. It includes questions about writing programs to find products using pointers, analyzing code snippets for output, and determining the correctness of given code. Additionally, it emphasizes the importance of understanding concepts rather than relying on external sources for answers.

Uploaded by

ans78hu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

C++ Assignments - Pointers - Week 4

The document contains C++ assignments focused on pointers for Week 4. It includes questions about writing programs to find products using pointers, analyzing code snippets for output, and determining the correctness of given code. Additionally, it emphasizes the importance of understanding concepts rather than relying on external sources for answers.

Uploaded by

ans78hu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C++ Assignments | Pointers | Week 4

Q1 : Write a program to find the product of two numbers using pointers.

Q2 : int *p, q;

p is a pointer and q is an integer.


p and q both are pointers.
P and q both are integers.
Syntax is incorrect.

Q3: Find the output of the following code snippet.

int a = 10, b = 20;


int *ptr = &a;
b = *ptr + 1;
ptr = &b;
cout << *ptr << ‘ ‘ << a << ‘ ‘ << b;

11 11 10
10 10 10
11 10 11
10 11 10

Q4: Find the output of the following code snippet.

int a = 15, b = 20;


int *ptr = &a;
int *ptr2 = &b;
*ptr = *ptr2;

ptr now points to b


ptr2 now points to a
a gets value of b
b gets value of a

Q5: Is the following program snippet correct?


int a = 10, b = 20;
int *ptr;
*ptr = 5;

Note:- Please try to invest time doing the assignments which are necessary to build a strong foundation.
Do not directly Copy Paste using Google or ChatGPT. Please use your brain .

You might also like