Answer to Question #343456 in C++ for Yusuph

Question #343456

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

1
Expert's answer
2022-05-22T18:11:17-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS