How to directly add basic calculation signs in c programming? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to directly add basic calculation signs in c programming?

I was just trying to program in c. I'm using cell phone rather than pc. I wanted program calculator, where you can directly give input like 2+3 which will give answer 5 rather than preselecting the operator. I can initialize two float or integer for number input using scanf to call the user input. BUT HOW CAN I MAKE THAT OPERATOR USER INPUTABLE? Please, if anyone have good idea on it, it will be highly appreciate. May you have simple solution, but I being beginner had a lot of problems on it. Your help is highly appreciated.

8th Sep 2020, 3:54 AM
Tenzin Dorji
Tenzin Dorji - avatar
5 Answers
+ 2
You can write the input statement as follows- float x,y; char op; scanf("%f%c%f, &x, &op, &y); This will automatically break up 5+2 into individual groups. Make sure you dont include spaces in the input format. It shouldn't be something like 5 + 2. Avoid spaces.
8th Sep 2020, 4:35 AM
Charitra
Charitra - avatar
+ 1
Thank you very much and really sorry I couldn't upvote your kind help for me. It says my account is not activated. I couldn't get where to activate my account. I couldn't find in settings nor in my mail. Hope you won't mind. Really appreciated your kind help.. Thank you
8th Sep 2020, 5:48 AM
Tenzin Dorji
Tenzin Dorji - avatar
+ 1
No problem bro... you can add your email sort of thing, then it will automatically do it for you.. You can open your account in a PC, then do the activation. This might help
8th Sep 2020, 5:50 AM
Charitra
Charitra - avatar
+ 1
Thank you. I will try. Since I'm home under lockdown coz of Corona, I don't have access to PC. Once I'm back I will try as you said. Thanks
8th Sep 2020, 5:58 AM
Tenzin Dorji
Tenzin Dorji - avatar
+ 1
Tenzin Dorji Most welcome bro
8th Sep 2020, 6:00 AM
Charitra
Charitra - avatar