How do I return to a specific point in main if user input wrong data.

+2 Number Double07 · February 21, 2015
Okay, so I know that if I put return main ( ) in my main function, it will return to the start of the main.  How do I return to a specific line of code and retain the information previously entered?  In my code, I ask the user three things, but in the second question, they must enter a value between 0 or 1 (float) or they need to enter the value again.

int main()
{
    Newspaper tNewspaper;

    cout tNewspaper.Ads_Shown;

    cout tNewspaper.Percentage_User_Ads;

    if (tNewspaper.Percentage_User_Ads > 1.0000000)
    {
        if (tNewspaper.Percentage_User_Ads < 0.0000000)
        {
                cout

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
0 Altaf Husain Neva · February 26, 2015
No Problem Dear, Everyone here is either to learn or to teach. Learn whatever you don't know and teach whatever you have got until now.
0 Troy Jones · February 26, 2015
I've heard using goto is bad programming practice, but that doesn't mean it won't work....
0 Altaf Husain Neva · February 26, 2015
Yuppp it is bad  when used with iteration that is loop or some recursive blocks where the chances of deadlocks are there. In this there is no issue.
  • 1
  • 2

C++

107,097 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator