#include <iostream> using namespace std; int main(){ float a,b; for(int i=1;i<1000;++i){ cin>>a; cin>>b; flo | SoloLearn: Learn to code for FREE!

0

#include <iostream> using namespace std; int main(){ float a,b; for(int i=1;i<1000;++i){ cin>>a; cin>>b; flo

someone please make a an exception for me so that one can't enter strings or characters

ian

12/10/2017 4:20:14 PM

Ian

1 Answer

New Answer

0

You already can't add strings or characters. When cin encounters a character/string, it stops parsing the input. So if you input 7.15Kg, cin will stop parsing at 'K', leaving you with 7.15. Here is an example https://code.sololearn.com/c9pY1Gx0Iz1y/#cpp