i want to stop loop by entering any character like "n" in int type variable.The problem is that i cant enter character in int type variable . Any one can help me ?
The problem is that i cant enter character in int type variable
You can. If the stream detects a non numeric character for a numeric variable it will enter the error state. cin (or any other stream) will return false which you can use to end the loop:
1 2 3 4 5
int i;
while(cin >> i)
{
...
}
After the loop is done use clear() to clear the error state: