scanf("%lf",&alpha);
alpha = (alpha * PI)/180;
if(alpha==PI/2)
{
printf("0");
}
i also defined PI and declared alpha...it just skipping this if and i don't know why
scanf("%lf",&alpha);
alpha = (alpha * PI)/180;
if(alpha==PI/2)
{
printf("0");
}
i also defined PI and declared alpha...it just skipping this if and i don't know why
Equality and floating point numbers do not go down well. You have rounding errors.
Need to put in some tolerance.
#include <stdio.h>
double PI = 3.14159265359;
int main (void)
{
double alpha = 90.0;
scanf("%lf",&alpha);
alpha = (alpha * PI)/180;
if(alpha==PI/2.0)
{
printf("0");
}
}
Enter 90 and the 0 gets printed. Works as expected, did you declare alpha as float? Then you would have to change the scanf to "%f" to get correct results.