C Program to demonstrate the ‘atof’ and ‘gets’ functions.

C Program to demonstrate the ‘atof’ and ‘gets’ functions. atof function converts the intial nptr string to the double. atof means ASCII to float. gets function reads string from the input stream. puts function prints string to the output stream This program will multiply to floating point numbers. The program will accept invalid data, and give you crap results as a result. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



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

main()
{
char str1[80], str2[80]; /* define a couple o' strings. */
double result; /* Result of multiplication. */

puts ("This program will multiply to floating point numbers.");
puts ("The program will accept invalid data, and give you");
puts ("crap results as a result.n");
puts ("Please enter the first number.");
gets(str1);

puts ("And the second.");
gets(str2);

result = atof(str1) * atof(str2);
printf("Answer is %8.2fn", result);
}


Read more Similar C Programs
C Strings

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com