ADVERTISEMENT
ADVERTISEMENT

Home » Code Snippets » C/C++ Code Snippets

C program to print value in exponential (scientific) format.

By: IncludeHelp, On 26 OCT 2016

ADVERTISEMENT

In this c program, we will learn how to print float or double value in exponential (scientific) format in c programming language?

Which format specifier specifies exponential format?

%e can be used to print value in exponential format of float or double value.

Let’s consider the following example - in this example there is a float type variable value and which is assigned by 123456.456 and value of variable value is printing using %f and %e format specifiers.

C program - Print value in Exponential Format

/*C program to print value in exponential (scientific) format */

#include <stdio.h>
int main()
{
	float value=123456.456f;
	
	printf("value: %f (using %%f format specifier)\n",value);
	printf("value: %e (using %%e format specifier)\n",value);
	
	return 0;
}
    value: 123456.453125 (using %f format specifier)
    value: 1.234565e+05 (using %e format specifier)
ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.