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

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

By: IncludeHelp, On 26 OCT 2016


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)



Copyright © 2024 www.includehelp.com. All rights reserved.