Cpp | Sololearn: Learn to code for FREE!



How can i write a code that can accept letter not the number in c++ Forexample enter name The user must have to enter its name in letter when the user enter the number it have to notify him note to use number help me guys

7/29/2018 10:01:17 AM

bereket mekurya

3 Answers

New Answer


with cin of string data type, one can accept value as 123 because it is considered as "123" ... One should convert input to double or int and check whether conversion passes or not...


string name; cin >> name;


https://code.sololearn.com/cY49wQLjgnId/?ref=app This will keep asking for the name until the user types the correct one. Warm regards