9. Converting the angle- the solution


​#include <stdio.h>
/*
The angle is given in degrees to two decimal places. Write a program that expresses the given angle
 in degrees and minutes. For example, represent 60.25 as 60 degrees and 15 minutes.
*/
int main()
{
double angle;
int degrees,minutes,remainder ;
    printf("Enter the angle in degrees\n");
    scanf("%lf", &angle);  //60.25

  /*side effect of casting, i.e. converting angle variable to type int,
    will lead to rounding to the first smaller whole number, i.e. the decimal part will be discarded
    */
degrees=(int)angle;  //degrees= 60
remainder =(angle-degrees)*100;    //remainder ​= 25

  /*remainder : 100 = minutes: 60, because 1 degree = 60 minutes, not 100*/
minutes=remainder *60/100;   //minutes=15

    printf("%2d degrees and %2d m minutes",degrees,minutes);

return 0;
}