Convert string to double: How to use atof: sines calculator
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main ()
{
double n, m;
double pi=3.1415926535;
char str[256];
printf ( "Enter degrees: " );
gets ( str );
n = atof ( str );
m = sin ( n * pi / 180 );
printf ( " sine of %f degrees = %f \n" , n, m );
return 0;
}
Related examples in the same category