C Program to Check if Given Number is Integer or Float
Write C Program to Check if Given Number is Integer or Float
//WAP to check whether the given number is integer or float #include <stdio.h> #include <math.h> int main() { float n; printf("Enter the number :--> "); scanf("%f", &n); int x = floor(n); //typecasting float to int if ( x == n) { printf("The entered number is an integer\n"); } else { printf("The entered number is float\n"); } return 0; }
Output:
Run 1:
Enter the number :--> 98.3
The entered number is float
Run 2:
Enter the number :--> 89
The entered number is an integer