How do i check a user inputted variable's type? Like double, integer or char? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do i check a user inputted variable's type? Like double, integer or char?

9th Aug 2018, 6:19 AM
Oğuz Gözlü
Oğuz Gözlü - avatar
1 Answer
0
I think i explained the question a little wrong. I am making a calculator that calculates numbers until the user inputs -1 as a number. My calculation has a switch case loop which checks thw user inputted chars like +, -, *, / and %. When i declare the varibles as integers the code works just fine, but when i change integer to double or float i have an error about the char '%'. So i want to check if user enters a double or an integer. Then i can seperate the code and if user enters doubles i wont include the '%' case to my loop. Atleast thats what im trying to do. 😓
9th Aug 2018, 10:32 PM
Oğuz Gözlü
Oğuz Gözlü - avatar