is there a function in c that checks if n is a number code example
Example 1: check command line input is a number in c
bool isNumber(char number[])
{
int i = 0;
//checking for negative numbers
if (number[0] == '-')
i = 1;
for (; number[i] != 0; i++)
{
//if (number[i] > '9' || number[i] < '0')
if (!isdigit(number[i]))
return false;
}
return true;
}
Example 2: how to know if a number is even in c
if((x & 1) == 0)
printf("EVEN!\n");
else
printf("ODD!\n");