C program to convert string into floating-point value using atof() function.

#include<stdio.h>
#include<stdlib.h>

int main()
{
 char str[] = "12.54";
 float n;
 
 n = atof(str);
 
 printf("String value is %s \n",str);
 printf("Number is %f \n",n);

 return 0;
}
OUTPUT:

String value is 12.54
Number is 12.540000

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *