Question: How do I get the values of '*numPtr' and 'num' in main to be 10 using a pointer and having a void function 'addFive()' that
How do I get the values of '*numPtr' and 'num' in main to be 10 using a pointer and having a void function 'addFive()' that doesn't return a value?
***** BELOW - pointerPlay.cpp. ************
#include
using namespace std;
void addFive(int);
void addFive(int num) { cout << "The value of num in function: " << num << endl; num += 5; cout << "The value of num in function after adding 5: " << num << endl; }
int main(int argc, char const *argv[]) { int num = 5; int* numPtr = #
addFive(*numPtr);
cout << "The value of numPtr in main: " << numPtr << endl; cout << "The value of *numPtr in main: " << *numPtr << endl; cout << "The value of num in main: " << num << endl;
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
