Archived

This topic is now archived and is closed to further replies.

tkitts1965

C++ help needed

Recommended Posts

tkitts1965    122
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<

Share this post


Link to post
Share on other sites
Ironblayde    130
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

Share this post


Link to post
Share on other sites