Solution for Exercise 11-14
ex1114
#include <stdio.h>
int main()
{
float degrees,radians;
printf("Enter an angle in radians: ");
scanf("%f",&radians);
degrees = 57.2957795*radians;
printf("%.2f radians is %.2f degrees.\n",radians,degrees);
return(0);
}
Output
Enter an angle in radians: 3.14159
3.14 radians is 180.00 degrees.
Notes
* This solution involves swapping the degrees and radians variables throughout the code, but also specifying the number of degrees in a radian for the calculation in Line 9: 57.2957795
* The C language lacks conversion constants for degrees-to-radians and radians-to-degrees. But it does have a constant for π, defined in the math.h header file: M_PI. Use this defined constant to calculate the radian/degree conversion values as follows:
Copyright © 1997-2026 by QPBC.
All rights reserved
