GET ONY INTEGER FROM USER | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

GET ONY INTEGER FROM USER

How can I get only int from user? if user's input is not integer show message please eneter number instead of alpha then get input from user then save it in array again

27th Dec 2016, 10:56 AM
Matin Zadehdolatabad
Matin Zadehdolatabad - avatar
4 Answers
+ 6
int a; try { cin >> a; } catch (Exception){ cout << "Please input an integer value"; int a =0; return 0; }
27th Dec 2016, 11:58 AM
Wen Qin
Wen Qin - avatar
+ 2
@K2 Shape, is your code compiling?
27th Dec 2016, 12:24 PM
Shiv Kumar
Shiv Kumar - avatar
0
@K2 Shape can you edit my last code ..? project polynomial
27th Dec 2016, 12:08 PM
Matin Zadehdolatabad
Matin Zadehdolatabad - avatar
27th Dec 2016, 3:29 PM
Vladislav
Vladislav - avatar