Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Language%20in%20C%20Interview%20Questions%20and%20Answers

Question: How do I convert a floating-point number to a string?

Answer: Use function gcvt( ) to convert a floating-point number to a string. Following program demonstrates the use of this function.
#include <stdlib.h>

main( )
{
char str[25] ;
float no ;
int dg = 5 ; /* significant digits */

no = 14.3216 ;
gcvt ( no, dg, str ) ;
printf ( "String: %sn", str ) ;
}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook