|
| |||||||||
| Tags: c language, double, function, print, programming |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| printf double in c
Hello ! I am creating a simple program which requires to print the double variable.I am new guy for this programming language.I had looked from books but not getting anything.The printing statement for the Double variable has different format when we use in the programs!I am getting confused.Please suggest me a good way to do it. Thanks. |
|
#2
| ||||
| ||||
| printf double in c printf double in c The printf statement takes different ways to print the double data type values. here,I am going to show you the statement which will print the statement produced by double data type. Code: double value = 1.543605908721;
printf("Value 1.3lf", value); |
|
#3
| ||||
| ||||
| printf double in c
C displays both type of variables float and double upon to the six decimal places. it does not need to the precision of which the number is really collected. The implementation of the float an double data type would be as it Code: #include <stdio.h>
main()
{
int Add = 100;
char Character = 'Z';
float Adj1 = 23.567;
double Number2 = 11e+23;
printf("Integer variable is %d\n", Add);
printf("Character is %c\n", Character);
printf("Float variable is %f\n", Adj1);
printf("Double variable is %e\n", Number2);
} |
|
#4
| ||||
| ||||
| printf double in c
The style of statement for printing Double values is very different than the other variables.You can view this output and can measure the effect of printing statement.The Printf statement behavior can be changed for the double and float variables. Zecho writes the code,just execute it and find out the values which would be produced due to execution. The output of the above program would be - Integer variable is 100 Character variable is Z Float variable is 23.567000 Double variable is 11.000000e23
__________________ Grand Theft Auto 4 PC Video Game |
|
#5
| ||||
| ||||
| setting the precision for double in c setting the precision : You can change the precision of the double type values in the program using some little bit changes in the printf statement. To change the behavior of decimal places places for float and double type variables, you can edit the %f or %e to add the desired precision value. Code: printf("Value of double variable is %.2e\n",Doub_var ); You can put any desired number where 2 is placed,the output would be converted and displayed in the precision what you provide.
__________________ The FIFA Manager 2009 PC Game |
|
#6
| ||||
| ||||
| DATA TYPE CONVERSION with double and float DATA TYPE CONVERSION Just look at the following program : Code: #include <stdio.h>
main()
{
int val1 = 12, val2 = 5;
float result = 0;
result = val1 / val2;
printf("The value of %d divided by %d is %f\n",val1,val2,result );
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "printf double in c" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pirates of Black Cove, no missions after ‘Double-Double Crossing’ | Maee | Video Games | 7 | 28-12-2011 05:18 PM |
| Errors in printf() in c programming | RamBarose | Education Career and Job Discussions | 6 | 27-04-2011 11:36 PM |
| Problem of DNS and Double-NAT | visioneye | Networking & Security | 6 | 29-05-2010 07:38 AM |
| What is the printf() function of the C language | Tailor | Software Development | 5 | 27-02-2010 04:26 PM |
| Double clicking. | Tristan | Vista Help | 8 | 08-03-2008 11:55 PM |