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
Answer: Option
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 4 of 5.
Gana said:
1 decade ago
What is double ?
Klakston said:
1 decade ago
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.
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.
Klakston said:
1 decade ago
That question just only mentioned default real number so we using only float variable then why they used double. Just I need some more clarifications.
Chinna@RGUKT said:
1 decade ago
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?
Please tell me?
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?
Please tell me?
Rahul said:
1 decade ago
1. I need clarification where we use double and where we use float.
2. How data types are occupy the memory? If we gave int i=3 then it occupy the memory as 1 1 0 right or wrong and if we gave 3.2 how it will take.
2. How data types are occupy the memory? If we gave int i=3 then it occupy the memory as 1 1 0 right or wrong and if we gave 3.2 how it will take.
Rathika.b said:
1 decade ago
@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.
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.
Nagchandra said:
1 decade ago
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?
{
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?
Kavitha said:
1 decade ago
Double variable have more precision.
for eg.,
6/36=0.166666666
So we can get more over approximate value
for eg.,
6/36=0.166666666
So we can get more over approximate value
Aman said:
1 decade ago
Hello Cheluvarajesh.
Double variable is always bigger than the Float variable whether the values are same.
Double variable is always bigger than the Float variable whether the values are same.
Subhalaxmi said:
1 decade ago
Real number consists of both rational & irrational number.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers