Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please Help.....

Hadi RehmanHadi Rehman Member Posts: 1

this is my Code

include "stdafx.h"

include

include

using namespace std;

bool ask() {

cout << " Enter Y/N " << endl;
char response;
cin >> response;
return (response == 'y') || (response == 'Y');

}

int main() {
bool result;
const int length = 2;

do
{
    for (int i = 1; i <= length; i++)
    {
        cout << " Enter Name "; // ask name 
        string ASK;
        getline(cin, ASK);
        cout << ASK << endl;
        }
    result = ask(); 


} while(result);

}

whenever i enter name and then it ask for return value whenever i enter true value 'Y' its starts loop again but ignores first loop like this

Enter name
Enter name John
John
Enter Y/N>

Tagged:
Sign In or Register to comment.