Howdy, Stranger!

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


Please Help.....

Hadi RehmanHadi Rehman Member Posts: 1

this is my Code

include "stdafx.h"



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;

    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
Enter Y/N>

Sign In or Register to comment.