- 3
What is the c program to check number Is even or odd or a letter(like a,A,s etc) or a fractional number(2.23)
Can any one please send me the code https://code.sololearn.com/c0qblW5vyR8i/?ref=app https://code.sololearn.com/cTg9eDEOZI3M/?ref=app https://code.sololearn.com/cI90fHxGJUKC/?ref=app https://code.sololearn.com/cuWvxQ0VUJNH/?ref=app https://code.sololearn.com/crarONt5raM7/?ref=app https://code.sololearn.com/cMcsxE10taOz/?ref=app https://code.sololearn.com/cxzbaq7quqw3/?ref=app https://code.sololearn.com/ctXpy2gqo7st/?ref=app https://code.sololearn.com/cVqPtuRcbP9Q/?ref=app https://code.sololearn.com/cR53iGTq2vZt/?ref=app https://code.sololearn.com/cVgYoN1vOnqP/?ref=app
4 odpowiedzi
0
You can check numbers divisibility using modulo operator %.
When A % B == 0, then A is divisible by B.
Even means being divisible by 2 and odd means not being divisible by 2, so C is even when C % 2 == 0, and odd when C % 2 != 0.
a float (other than ±inf) is always a fraction number.
0
Ok
0
I'll explain how but you really need to try it yourself. You can check a number if it's even or odd just by operate the number with modulo 2 (n%2 ? "Odd" : "Even").
You can check if the number is fractional by using an int types (int, long, ll), take the number and assign in to a float variable and then assign it again to the int variable, compare it (i==f ? "Integer" : "Fractional").
You can check if your input is a letter by using isalpha() (included in ctype).