Loop back to the beginning or terminate

Ok, I have found the code for a really simple program that allows you to check the number value of individual characters. IE= 1, g, ;.

What I am wanting to do is have the program return the value and then ask the user if they want to get the value of another value.

If the user enters ('y', return) then I want the program to start over again.

If the user enters ('n', return) then I want the program to terminate.

I have 'C++ for Dummies' and 'The C++ Programming Language' but I also need a little guidance to help figure some stuff out.

Thanks for any help.
1
2
3
4
5
6
7
char choice;

do{
 ... your program goes here

cin >> choice;
} while(choice != 'n');
Thanks,

That code is something I think I will end up using alot. Thanks!
I decided to see if I could add a couple lines (6, 7) just to see if it would work and lo and behold it did!

Thanks again!

1
2
3
4
5
6
7
8
9
10
char choice;

do{
 ... your program goes here

cout << "Do you want to find the value of another character? (y/n)"
         << endl;

cin >> choice;
} while(choice != 'n');
Last edited on
Topic archived. No new replies allowed.