I am currently stuck on this question but don't know what I am doing wrong:
Complete the function add10() to make the program can add 10 to each user input integer number. (NOTE: you should only change the code for function add10() . Do NOT change other code.)
The original code provided to me is this:
#include <iostream>
#include <iomanip>
using namespace std;
//TODO: complete this function, do NOT change other code
void add10()
{
}
//Please do NOT change the following code
void main()
{
int n;
cin >> n;
add10(n);
cout << n;
}
I have edited the above code as shown below, but it still returns the same value as the user input:
#include <iostream>
#include <iomanip>
using namespace std;
//TODO: complete this function, do NOT change other code
int add10(int n)
{
return n += 10;
}
//Please do NOT change the following code
void main()
{
int n;
cin >> n;
add10(n);
cout << n;
}
Can someone please help me explain how to fix my code and what I am doing wrong? Thanks!