Use three functions to perform the following tasks:
- Accept two integers from user. A function capture should do this using its
local variables fnum and snum.
- Modify the contents by multiplying the original values by 10. The function
modify should modify the values of fnum and snum as stated.
- Display the new value to the user. The function display should print to the
user the new values of fnum and snum variables.
#include <iostream>
void capture(int& fnum, int& snum)
{
std::cout << "Please enter fnum: ";
std::cin >> fnum;
std::cout << "Please enter snum: ";
std::cin >> snum;
}
void modify(int& fnum, int& snum)
{
fnum *= 10;
snum *= 10;
}
void display(int fnum, int snum)
{
std::cout << "New value fnum=" << fnum << std::endl;
std::cout << "New value snum=" << snum << std::endl;
}
int main()
{
int fnum, snum;
capture(fnum, snum);
modify(fnum, snum);
display(fnum, snum);
return 0;
}
Comments
Leave a comment