Mega Code Archive

 
Categories / C / String
 

Convert string to double

#include <stdio.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; }