can u please help me to make this program..a program that decide and accept y for yes and N for no.y to repeat the process and no for the exit of the program..
ASAP PLS..TENKS

What do you have so far? We do not give out the answers to homework problems. You need to show effort before we help.

ASAP PLS..TENKS

WOOF! NO PRAPLEM.

#include <iostream>
#include <cctype>
#include <algorithm>

using namespace std;

int main()
{
    string answer;

    do
    {
        cout << "Enter \"y\" or \"n\": ";
        getline(cin, answer);

        // Trim whitespaces before/after input. We tolerate those.
        answer.erase(find_if(answer.rbegin(), answer.rend(), not1(ptr_fun<int, int>(isspace))).base(), answer.end());
        answer.erase(answer.begin(), find_if(answer.begin(), answer.end(), not1(ptr_fun<int, int>(isspace))));

        if (answer.size() > 0)
        {
            // Convert the entered character to lowercase.
            answer[0] = tolower(answer[0]);

            // Allow whitespaces after our input, but nothing else.
            if ((answer[0] != 'y' && answer[0] != 'n') || answer.size() > 1)
            {
                cerr << "Invalid input!\n";
            }
        }
        else
        {
            cerr << "Please provide input!\n";
        }
    }
    while (answer.size() == 0 || answer[0] != 'y');

    return 0;
}

-edit-

Oh oops, post looks silly after that reply I guess. Mods/admins may remove the code/post if needed.

Edited 3 Years Ago by Gonbe

/there you go mate..just follow this simple programme...any issues with it,just get back to me/

declare variables
char first;
char second = 'n';
char firstName [] = "john";//character array
char secondName[] = "ciaran";//char array//if you specify the char amount in []
// it will allow only that many char
cout<< "do you want to continue ?"<<endl;
cin>>first;
if (first=='y')

{ cout<< "you typed  "<<first <<"  so you want to continue "<<secondName<<endl; }

else if (first='n')
{cout<<"goodbye "<<firstName<<endl;}

else {cout<<"what do you want to do next? \n";}


system ("pause");
return 0;
}
//end of main
This article has been dead for over six months. Start a new discussion instead.