C++ help needed

Started by
0 comments, last by tkitts1965 23 years, 6 months ago
OK I am stuck how do I make my program continue indefinitely? With out writing it over and over. I want it to function until I tell it to stop. I can make it repeat once, I want it to repeat indefinitely. #include double sqrt (double a, double b) { return 0; } double sqrt( int a, int b, int c ) { cout< #include #include #include #include void main( void ) { srand(time(0)); cout<<"\t********************************************************\n" <<"\t* *\n" <<"\t* The Pythagorean Theorem *\n" <<"\t* *\n" <<"\t********************************************************\n\n"; double a,b,c; cout<<"Please enter two numbers:"<> a; cout<<"\nSecond number: "; cin>> b; cout<<"\n"; c=sqrt(a,b); cout<<"\n"; c=sqrt(a*a+b*b); //a2 + b2 = c2 cout<>choice1; //playing } while((choice1!=''Y'') && (choice1!=''y'') && (choice1!=''N'') && (choice1!=''n'')) { cout<>choice1; } if ((choice1 == ''Y'') || (choice1 == ''y'')) //If yes, start over again { cout<> a;cout<<"\nSecond number: "; cin>> b; cout<<"\n"; c=sqrt(a,b); cout<<"\n"; c=sqrt(a*a+b*b); cout<<c<<endl; cout<<"\n"; } else if((choice1 == ''N'') || (choice1 == ''n'')) //If player quits show him this { srand(time(0)); cout<<"\t********************************************************\n" <<"\t* *\n" <<"\t* Thank you for playing. *\n" <<"\t* *\n" <<"\t********************************************************\n\n"; } }
Advertisement
Well. You just use a loop!

do
{
// your code here
// get ''y'' or ''n'' from user
} while (ch == ''y'');

I strongly suggest that you pick up a book on basic C. And for programming help, post in "Game and General Programming" rather than this forum -- it''s not the place for it.

-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"

This topic is closed to new replies.

Advertisement