I'm creating a simple program which will check whether the value of sin and cosine of an angle is equal to 1 or not i typed this code
#include <stdio.h>
#include <math.h>
int main()
{
int x;
printf("Enter the value of angle in degree: \n");
scanf("%d",&x);
double rad = 0.0174533*x;
double sum = pow(sin(rad),2) + pow(cos(rad),2);
printf("%f",sum);
if (sum == 1)
printf("\nsum of squares of sine and cosine is equal to 1");
else
printf("\nsum of squares of sine and cosine is not equal to
1"); return 0; and it says the sum is not equal to 1 that is the else block is executed while if i change the code to
#include <stdio.h>
#include <math.h>
int main()
{
int x;
printf("Enter the value of angle in degree: \n");
scanf("%d",&x);
double rad = angle*3.14/180;
double sum = pow(sin(rad),2) + pow(cos(rad),2);
printf("%f",sum);
if (sum == 1)
printf("\nsum of squares of sine and cosine is equal to 1");
else
printf("\nsum of squares of sine and cosine is not equal to 1");
return 0;
It works fine how??