Floating Point Numbers + C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
#include<conio.h>
float square(float);
void main()
{
    clrscr(); 
    float a,b;
    printf("ENter a Number");
    scanf("%f",&a);
    printf("Number=%f",a);
    b=square(a);
    printf("\nSquare of %f is %f",a,b);
   getch();
}

float square(float x)
{
    float y;
    y=x*x;
    return(y);
}


In the above program, I am calculating the square of float number. But sometimes the number is entered as NAN and sometimes Output is NAN. What is NAN? I am entering floating point number, then y NAN is entered?
Last edited on
Not a Number. It means the input couldn't be interpreted as a floating point number.
Topic archived. No new replies allowed.