In C, decimal values are called "floating point" because the number of digits after the decimal point can vary. There are two types used for floating point operations: float and double.
Although the decimal point can shift anywhere within the number, C only allows a certain number of consecutive digits worth of precision. The float type only allows 7 consecutive digits, and the double type allows 15. Any digits before and after those consecutive digits are generally displayed as zero (0).
Here's an example program that uses the float type with arithmetic operators:
#include
void main()
{
float myfloat=0.0, counter;
printf("* perform addition on the float:\n");
for (counter=5; counter<10; counter++) {
myfloat+=(counter/10);
printf("myfloat is: %0.7f\n", myfloat);
}
printf("* perform subtraction on the float:\n");
for (counter=0; counter<5; counter++) {
myfloat-=(counter/10);
printf("myfloat is: %0.7f\n", myfloat);
}
printf("* perform multiplication on the float:\n");
for (counter=5; counter<10; counter++) {
myfloat*=(counter/10);
printf("myfloat is: %0.7f\n", myfloat);
}
printf("* perform division on the float:\n");
for (counter=2; counter<8; counter++) {
myfloat/=(counter/10);
printf("myfloat is: %0.7f\n", myfloat);
}
}
The %0.7f inside the printf() format string tells the compiler you want to display a minimal number of integer places, and no more than 7 decimal places. Play around with this value and see what happens.
If you compile and run this program, you may notice something odd. The last (right-most) decimal place has an errant number popping in. This is a result of the low precision of the float type. The following output is an example:
* perform addition on the float:
myfloat is: 0.5000000
myfloat is: 1.1000000
myfloat is: 1.8000001
myfloat is: 2.6000001
myfloat is: 3.5000002
* perform subtraction on the float:
myfloat is: 3.5000002
myfloat is: 3.4000003
myfloat is: 3.2000003
myfloat is: 2.9000003
myfloat is: 2.5000002
* perform multiplication on the float:
myfloat is: 1.2500001
myfloat is: 0.7500001
myfloat is: 0.5250000
myfloat is: 0.4200000
myfloat is: 0.3780000
* perform division on the float:
myfloat is: 1.8900001
myfloat is: 6.3000002
myfloat is: 15.7500000
myfloat is: 31.5000000
myfloat is: 52.5000000
myfloat is: 75.0000000
However, if you're displaying only a couple of decimal points, the discrepancy is generally unseen.
write a c++ program to convert binary number to decimal number by using while statement
This is not a question.
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
int a,b; a=a+b; b=a-b; a=a-b; that's it simple
How to write a program for secant method by mathematica
write a c++ program to convert binary number to decimal number by using while statement
write a c program to accept a number and generate a square root cube and exponential values
void mynullfunction () {;}
You divide percent values by 100 (or move the decimal two places to the left) to get the decimal equivalent: 723 / 100 = 7.23
You divide percent values by 100 (or move the decimal two places to the left) to get the decimal equivalent: 135.2 / 100 = 1.352
You divide percent values by 100 (or move the decimal two places to the left) to get the decimal equivalent: 1.83/ 100 = 0.0183
You divide percent values by 100 (or move the decimal two places to the left) to get the decimal equivalent: 72 / 100 = 0.72
You divide percent values by 100 (or move the decimal two places to the left) to get the decimal equivalent: 131.66 / 100 = 1.3166
You divide percent values by 100 (or move the decimal two places to the left) to get the decimal equivalent: 17 / 100 = 0.17
You divide percent values by 100 (or move the decimal two places to the left) to get the decimal equivalent: 625 / 100 = 6.25
This is not a question.
pongada punda vayanungala ..................