Function returning pointer to float in c

float * usa(){
    static float*  p,a=5>=5;
    p=&a;
    return p;
}
void main(){
    float *real;
    real=usa();
    clrscr();
    printf("%.2e",*real);
    getch();
}
Output: 1.00e+00

2 comments:

Anonymous said...

can anybody give the explanation of the above code ?

pawan said...

I guess you are confused by a = 5>=5, it is just a condition which checks if 5 is greater than or equal to 5. Since it is C language, it will return 1 or 0 instead of true or false. The result will be assigned to a, i.e. 1. And float representation of 1 is 1.00e+00.