After that, a single character from the alphabet will be entered. The program will then pint out a vowel or consonant based on what the user inputed. If the user input is not a letter between a-z or A-Z or if it is a string of length>1,
The program should print "You did not enter a letter of the alphabet".
#include <iostream>
#include <string>
using namespace std;
int main ()
{
cout<<"Enter your name please:"<<name<<endl;
string name;
getline(cin, name);
cout << "Enter a letter: "<<alphabet<<endl;
string alphabet= a-z||A-Z;
getline(cin,alphabet);
cout<<"The alphabet entered is:"<<alphabet<<endl;
// read string until the next separator
// (space, newline, tab)
// Or, alternatively:
// read a whole line into the string name
if (str.length >1)
{
cout << "You did not enter a consonant or vowel,"<< assign default<<endl;
alphabet = "a-z||A-Z";
}
else
{
cout << "Thank you, " << name << "for running this simple program!"<< endl;
}
}

New Topic/Question
Reply



MultiQuote






|