Question: I need to write a program in C++ where the user can do some computation, and when the computation is done, the program will ask the user if he wants to do another computation. I know how to write this in Python:

```
more = "y"
while (more == "y"):
    // computation code
    print "Do you want to do another computation? y/n "
    more = input()

```

I created a char variable and used it in the head of the loop, but I don't know how to implement the "input" function in C++. I tried using the cin.get(char\_variable) function but the program seems to skip it entirely.

Answer: 
If you used cin.get, you probably had the following problem. If you run this code:

```
cout << "give a number:";
int n;
cin >> n;
cout << "give a char:";
char c;
cin.get(c);
cout << "number=" << n << endl;

```

you'll get the scenario

```
give a number:12
give a char:number=12

```

where it seems the `cin.get()` was ignored. In fact it was not. It read the "end-of-line" you typed after the number. You'll see it by adding

```
cout << "char code=" << (int) c << endl;

```

to see the numeric value of the char.

--- you'd better use `cin >> c;`  instead because it waits for the first non-white char.
Your program is quite simple & easy. It goes like this :-

```
#include <iostream>
using namespace std;
int main()
{
    char ch='y';
    do
    {
        // compute....
        cout<<"do you want to continue ?: "<<flush;
        cin>>ch;
    }while (ch=='y' || ch=='Y');   // don't for get the semicolon
    return 0;
}

```

If you want to use `while loop` instead of `do while`, your code will be :-

```
#include <iostream>
using namespace std;
int main()
{
    char ch='y';
    while (ch=='y' || ch=='Y')
    {
        // compute....
        cout<<"do you want to continue ?: "<<flush;
        cin>>ch;
    }    // no semicolon needed as in `do while`
    return 0;
}

```

Simple ! Hope your code works.