Use three functionsto perform the following tasks:
modify should modifythe values of fnum and snum as stated.
-Modify the contents by multiplying the original values by 10. The function
-Display the new value to the user. The function displayshould print to the
local variables fnumand snum.
-Accept two integers from user. A functioncaptureshould do this using its
user the new values of fnum and snum variables.
#include <iostream>
int * capture(){
static int nums[2];
std::cout<<"Enter the first number: ";
std::cin>>nums[0];
std::cout<<"Enter the second number: ";
std::cin>>nums[1];
return nums;
}
void modify(int* nums){
nums[0]*=10;
nums[1]*=10;
}
void display(int* nums){
std::cout<<"First number: "<<nums[0]<<std::endl;
std::cout<<"second number: "<<nums[1]<<std::endl;
}
using namespace std;
int main()
{
//test
int* ptr = capture();
modify(ptr);
display(ptr);
return 0;
}
Comments
Leave a comment