I have just started learning c++, and I'm confused on one of my assignments.
Write a void function called increment that will increase the value of the argument passed into it by one.
Our main program should look like this:
1 2 3 4 5 6 7 8 9 10 11 12
int main(){
cout << "Please enter a number: ";
double n;
cin >> n;
cout << "The original number was: " << n << endl;
increment(n);
cout << "The number after increment is: " << n << endl;
I have:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void increment(int n)
{
n++;
}
int main(){
cout << "Please enter a number: ";
double n = 1;
cout << "The original number was: " << n << endl;
increment(n);
cout << "The number after increment is: " << n << endl;
}
It's probably something simple, but any help would be appreciated.