This is my course project for school, and my program is working for the most part, but when an incorrect pin is entered, the program pauses and closes out. I would like it to return to the main so that you can retry to enter a pin. I think my else statement is being skipped (obviously), but an explanation as to why and how to fix the issue would be much appreciated. I don't know if I can ask two questions in one post, but I can't seem to get my float to print two decimal points. How do I do that? I have researched both issues and cant seem to get anywhere on my own. I am using visual studio 2015 if that matters. Any other critiques of my code would be appreciated as well. Cheers!
int main()
{
int pin = 0;
int keypin;
keypin = 2000;
int comppin;
cout << "Enter your pin: "; // Checking user pin
cin >> pin;
cout << "\n\n";
comppin = (pin, keypin);
if (pin == 2000) // If correct print welcome screen
{
cout << "Pin Approved!\n";
}
else // When incorrect print below and return to main **planning to add attempts to this depending on how difficult that turns out to be
{
cout << "Incorrect pin. Try again. ";
return main();
}
system("pause");
return 0;
}
}