Question
Note: please write answer in the context of c++ language 1) Given an int x: Declare a pointer xptr to x. Use xptr to print
Note: please write answer in the context of c++ language
1)
Given an int x:
Declare a pointer xptr to x.
Use xptr to print out xs value.
Use xptr to assign a value of 7 to x.
Assign the address of xptr to a variable. What is its type?
2)What value should be assigned to a pointer that does not have a valid address?
3)
Given a string str:
Declare a pointer strptr to str.
Use strptr to print out strs value.
Use strptr to assign the value abc to str.
Use strptr to print out strs length.
4)
Given the following array and pointer declarations:
int arr[] { 1, 2, 3, 4, 5 };
int* arrptr = arr;
what is the output of each of the following statements? (assume they are not executed consecutively)
- cout << *arrptr;
- cout << *arrptr++;
- cout << *++arrptr;
- cout << ++*arrptr;
- cout << (*arrptr)++;
Write a statement that finds the number of elements in arr.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started