Hello I wrote this program to except user input parameters for a complex number in polar from then convert them to a + jb format. But I used the cos() function in the math.h libbary and it keeps giving me the answer in radians not in dergees. For example if I input the paratmerers Z=1 and Theta=90 it should return 0+1j but it does'nt it gives me -0.448074+51.222233j instead. Can someone please point out to me where I am making a mistake and how to fix it.
Thank you.
Code:
int main()
{
float Real, Complex, Z, Theta;
float pi;
pi = 3.141592654;
printf("Please enter Z: ");
scanf("%f",&Z);
printf("Please enter theta: ");
scanf("%f",&Theta);
Real = Z*(cos(Theta));
Complex = sin(Theta)*(180/pi);
if(Real > 0 && Complex > 0)
{
printf("The number is %f+%fj \n", Real, Complex);
}
if(Real > 0 && Complex < 0)
{
printf("The number is %f%fj \n", Real, Complex);
}
if(Real < 0 && Complex > 0)
{
printf("The number is %f+%fj \n", Real, Complex);
}
if(Real < 0 && Complex < 0)
{
printf("The number is %f%fj \n", Real, Complex);
}
return 0;
}