Jul 29, 2013 at 9:06am UTC
am trying to make a menu that have a restriction using alphabet.
and want to know how to implement a condition containing (ascii).
how do i make a condition that only accept certain letters to my entered by the
user??
[code]
#include<iostream>
#include <stdlib.h>
using namespace std;
int main()
{
char ascii;
cout<<"enter letter ";
cin>>ascii;
if ((int)ascii >97 && (int)ascii <101)
{
cout<<"echoing...please enter a valid choice\n";
}
}
Jul 29, 2013 at 11:39am UTC
your code seems to working fine whats wrong with it?
Jul 29, 2013 at 10:18pm UTC
oh yeah i just want to restrict the users choice from (a-e ) only..
Jul 29, 2013 at 10:41pm UTC
you want the >= and <= comparisons respectively. You are only searching 98-100
Jul 29, 2013 at 11:43pm UTC
@abstraction : what if 'b' is entered? will the condition fail? coz i want leters (a,b,c,d,and e) to be the valid input otherwise says "invalid input pease try again";
thanks
Aug 8, 2013 at 10:42am UTC
@metulburr
sorry boss
ok i will try .. very sorry for asking such stupid question..