I see your code in comments, note that was corrupted during paste in comment.
The code contain numerous syntax errors, without even speaking about its logic.
A few rules:
- Never call main() from any place in code.
cout<< main();
- Any command ends with a semicolon
cout<<"would you like to try another integer (y n)?\n cin>>answer;; // 2 semicolon at the end is an error
// prefer
cout<<"would you like to try another integer (y n)?\n; cin>>answer;
- Advice: do not put multiple command on same line of code, it works, but it also make code more difficult to read.
cout<<"would you like to try another integer (y n)?\n ;
cin>>answer;
- Quotes always goes by pairs
cout<<"would you like to try another integer (y n)?\n";
cin>>answer;
-
int get_number(void)
{
int num;
cout<<"Enter a number\n";
cin>>num;
if(num<1)
cout<<"This number is unacceptable. Please enter another number"<<endl;
else
return num;
}
Advice: rewrite the program as a single piece of code in main() until it works, then analyze the code to see which part can be made a function (the part that make the function will be replaced in main code by the function name.
How to make a function for a piece of code is a skill you have learn.
Learn debugger as soon as possible.
Debugger - Wikipedia, the free encyclopedia[
^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]
Basic Debugging with Visual Studio 2010 - YouTube[
^]
1.11 — Debugging your program (stepping and breakpoints) | Learn C++[
^]
The debugger is here to only show you what your code is doing and your task is to compare with what it should do.