C++/C program
Expert: vijayan - 10/19/2009
QuestionHi! i have a code running but i want to know, how do i run the program and in the end it asks the user if he wants to run the program again and if yes run it again with the new values he inputs or exit he doesn't want to. My program asks user few values and displays the result.
Thank You
AnswerPut the code for your program in a simple loop, which repeats if the user answers 'y' to the question "do you want run the program again?
#include <iostream>
int main()
{
char again = 'y' ;
while( again == 'y' )
{
// your program code here
std::cout << "do you want run the program again? (y/n) " ;
std::cin >> again ;
if( again == 'Y' ) again = 'y' ;
}
}