# C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 6)
6.
By default a real number is treated as a
float
double
long double
far double
Explanation:

In computing, 'real number' often refers to non-complex floating-point numbers. It include both rational numbers, such as 42 and 3/4, and irrational numbers such as pi = 3.14159265...

When the accuracy of the floating point number is insufficient, we can use the double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float.

To extend the precision further we can use long double which occupies 10 bytes of memory space.

Discussion:
50 comments Page 1 of 5.

There are three types of constants:
1)Integer constants.
2)Real constants.
3)Char constants.

INTEGER CONSTANTS:
* It is have atleast one Digits.
* It must not have decimal point value.
* Normal unsigned value mentioned Positive

REAL CONSTANTS:
There are two types Real constants form:Fractional form, Exponential form.
Fractional Form:
* It is have at least one Digits.
* It must have decimal point value.
* Normal value mentioned Positive.
Exponential form: That constants should be used 'e' exponent.value declared before 'e' that is called "Mantissa".

CHAR CONSTANTS:
Char constants nothing but a single alphet,single digits,single symbols enclosed inverted commas. like 'A' or '1' or '='.
So Decimal value should be mentioned Real constants and then Float and Double are keywords of Real constants.

Sundar said:   8 years ago

void main ()
{
float a=1.1;
if(a>1.1)
printf("welcome");
else
printf("bye");
getch();
}

Why the output is welcome please tell?

Float a=1.1 is considered float.

But, if (a>1. 1) there, 1.1 is real constant considered double. So, when using relation operators, type conversion accrued, the float convert to double, the padding accrued to value changed comparison time is not equal. Clearly you want, search about type conversion, how to changed the value in 0 1 padding time.

@Nagchandra
We know how machine language gets work.Compiler can convert our all source codes to 0's & 1's. Float can occupy memory space:4 bytes. Double can occupy memory space:8 bytes. so, if we specify float a=1 or double b=1 it considered as 4bytes & 8bytes respec with same value as 1.0000etc. but if we specify float a=1.1,double b=1.1 the bit values for float and double may be unequal.so, it shows the result based on the condition.

I have 2 questions

1. What you mean by double precision ?
2. Consider the following code

void main()
{
float a=1.1;
double b=1.1;

if(a==b)
{
printf(" I love you\n");
}
else
{
printf(" I hate you\n");
}
}

If you execute this code you will get output as I hate you..
How this is happening ?

Friends I have one doubt, would you clarify?
in ANSI C,
The precedence order is !, ~, ++, --, +, -, *, (type) , sizeof.
But, in Let Us C,
The precedence order is -, ++, ~, !, &, *, (type) , sizeof.
What is the correct order?

Another doubt is.
In ANSI C, comma (,) operator associativity is left to right.
But in Let Us C, right to left.
What is the correct associativity?

void main()
{
float a=1.1;
double b=1.1;

if(a==b)
{
printf(" I love you\n");
}
else
{
printf(" I hate you\n");
}
}

Output: I hate you

void main()
{
float a=1;
double b=1;

if(a==b)
{
printf(" I love you\n");
}
else
{
printf(" I hate you\n");
}
}

Output: I love you

How this will happen if we consider var equalization?

Aafreen said:   9 years ago
Real number means all the numbers in the number line.. So, we never ever know the number after the number 1. It may be 1.00000000000000000000...

So, we can't define it as float due to small precision.
It can be defined using double/long double.

So, the answer double is correct.

Basu said:   8 years ago
A rational number is a number that can be written as a ratio. That means it can be written as a fraction, in which both the numerator (the number on top) and the denominator (the number on the bottom) are whole numbers.

Rekha said:   6 years ago
I have a doubt. What is the difference between the following terms?

Int a; and int a=20;
And
Int a=b,b=20;
Printf("%d",a);

What will be the output causes if the values consider first a = b or b values.
(1)