Mega Code Archive

 
Categories / C Tutorial / Data Type
 

Use the %E in printf() to display scientific-notation numbers

#include <stdio.h>   int main() {     float lightyear = 5.878E12;     float jupiter = 483400000;     float distance;       distance = jupiter/lightyear;       printf("Jupiter is %E light years from the sun.\n",distance);       return(0); } Jupiter is 8.223886E-005 light years from the sun.