I have a class assignment of writing a program that:
Start with the following program code. Write the function called "increment" which takes one integer parameter and returns that value plus one.

#include 
#include 

using namespace std; 

// YOUR FUNCTION GOES HERE!

int main() 
{ 
	int input;
	string keepGoing;

	do
	{
		cout << "Please enter an integer: ";
		cin >> input;
		cout << "Your number plus one is ";
		cout << increment(input);
		cout << endl << "Do you want to continue (yes or no)? ";
		cin >> keepGoing;
	} while ((keepGoing == "yes") || (keepGoing == "YES"));

}

so far, i have modified it to produce the following, but there are errors and i dont think i know how to fix this. can anyone please help?

#include <iostream>
#include <string>

using namespace std;

// put increment function here?

int increment(int x){
return ++x;
}

int main()
{
string keepGoing = "increment(keepGoing)";

int input, total = increment(keepGoing);

do
{
cout << "Please enter an integer: ";
cin >> input;
cout << "Your number plus one is ";
cout << increment(keepGoing);
cout << endl << "Do you want to continue (yes or no)? ";
cin >> keepGoing;
} while ((keepGoing == "yes") || (keepGoing == "YES"));
return (0);

}

THANKS!!! :)

why did you change main() ? All you had to do was write the increment() functions.

Just delete the crap you wrote and start again. This time only change line 6 where it says to

put increment function here?

. DO NOTHING MORE other than correct lines 1 and 2 to include the header file names.

oh wow.
that's really quite stupid of me. i wasn't thinking.
thanks tho!

Wow that's a badly named function. "increment" doesn't mean "return the thing that's one bigger" (that would be called "successor" or something like that). "increment" usually means "take this variable and change it so that it is one bigger".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.