I am trying to make a small program to help do some math for a small business. I have an If Else Statement accepting the input of all numbers and works properly with numbers >= 0 && numbers <= 99,999. I have the else statement puts a statement saying Please type a number (0 - 99,999) and then it asks for the amount again. If I type a number that is out of the range this works. If I type a number in this range the program runs fine. If I type anything that is not a number or atleast a real number with a single decimal I get the infinite lop of doom and would love to fix it if at all possible. I'd like to stick with Basic C code please Thank You in Advance :)
C Code. If Else Statement. How do you get only numbers to work and not Letters/Words?
- Posted:
- 3+ months ago by JoeTweak2...
- Topics:
- work, number, program, letter, math, maths, numbers, word, code, statement
Added 3+ months ago:
The program is using a if else statement with 3 different if statements inside the if side of the if else statement and like I said this is a very small program like 9kb or so.... So I am using go to beginning and have the "Please Enter The Number:" and then the scanf("%f", &Cost); after beginning: outside all the loops at the start just after int main(void). SO all 3 if statements on the inside of the program are using go to beginning; at the end to loop the program back to the start and request a new number for the "Cost" amount before going back into the if statement sections based on that number. ....... Oh and I checked decimals... Multiple decimals work with numbers at least not in a death loop sense!!!!
Added 3+ months ago:
Please don't respond if you just want to talk trash. That is not answering a question. Also this is being done during my free time for free MIRCAT so Thanks for other then honorable answer!!!