Validating numeric values in c

Posted by / 26-Feb-2020 19:48

Validating numeric values in c

Note that this function chooses to discard all the remaining input on the line.Other possible choices are to discard just the next character or word. The outer loop keeps going until the user successfully enters an integer, causing .Following is the declaration for isdigit() function.

It may also need to check that the values are within acceptable limits.

Another kind of error is to enter values that are not valid for the particular task the program is doing.

Suppose, for instance, that you had a loop that processes nonnegative numbers.

One kind of error the user can make is to enter a negative number.

You can use a relational expression to test for that: loop condition is "while input is an integer and the integer is positive." The last example terminates input if the user enters the wrong type of value.

validating numeric values in c-59validating numeric values in c-29validating numeric values in c-62

Similarly, ' A' is used instead of 65 and ' Z' is used instead of 90.

One thought on “validating numeric values in c”