"Akhil" <ak*************@gmail.com> writes:
#include<stdio.h>
int main()
{
int a=1;
float b=1.0;
float c=1.1;
double d=1.1;
long double e=1.1;
if(a==b) //true
printf("\ntrue");
else
printf("\nfalse");
if(c==d) //false
printf("\ntrue");
else
printf("\nfalse");
if(c==e) //false
printf("\ntrue");
else
printf("\nfalse");
if(d==e) //true
printf("\ntrue");
else
printf("\nfalse");
return 0;
}
Aside from your actual question, I'd like to make some more points
about your code.
You have a "\n" at the beginning of each string you print. It should
be at the end. If there's no newline at the end of your program's output,
it might not even appear, depending on the system.
Proper indentation makes code easier to read. So does judicious use
of whitespace.
"int main()" is acceptable, but "int main(void)" is preferred.
"//" comments are valid in C99, and are supported by many C compilers,
but they're not supported by the C89/C90 standard. They're also
discouraged in Usenet postings, since they can cause problems with
line wrapping.
Applying all these suggestions, your code becomes:
#include <stdio.h>
int main(void)
{
int a = 1;
float b = 1.0;
float c = 1.1;
double d = 1.1;
long double e = 1.1;
if (a == b) /* true */
printf("true\n");
else
printf("false\n");
if (c == d) /* false */
printf("true\n");
else
printf("false\n");
if (c == e) /* false */
printf("true\n");
else
printf("false\n");
if (d == e) /* true */
printf("true\n");
else
printf("false\n");
return 0;
}
(I also use braces ({ ... }) even for single statements in control
structures.)
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.