Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

wat's the o/p of pgm??

2 posters

Go down

wat's the o/p of pgm?? Empty wat's the o/p of pgm??

Post by Naveen Mon Mar 08, 2010 4:29 pm

float f=5.5;
double d=5.5;
if(f==d)
cout<<"Equal";
else
cout<<"Not equal";

i get not equal as o/p..
y is it so?

Naveen

Posts : 15
Points : 21
Join date : 2010-03-05
Age : 35

Back to top Go down

wat's the o/p of pgm?? Empty Re: wat's the o/p of pgm??

Post by Christopher Mon Mar 08, 2010 4:40 pm

r u asking in java or c++??? In c++, it is equal. But java is strongly typed language, so float and double are different. I think thaty u r getting not equal. not sure. ll give a try.
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

wat's the o/p of pgm?? Empty Re: wat's the o/p of pgm??

Post by Naveen Mon Mar 08, 2010 4:41 pm

Hey even in c++ i do get the sam o/p...
u jus check it out...

Naveen

Posts : 15
Points : 21
Join date : 2010-03-05
Age : 35

Back to top Go down

wat's the o/p of pgm?? Empty Re: wat's the o/p of pgm??

Post by Christopher Mon Mar 08, 2010 4:58 pm

i tried it. it s working fine. anyways it depends on the compiler we use. which compiler r u using??
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

wat's the o/p of pgm?? Empty Re: wat's the o/p of pgm??

Post by Naveen Mon Mar 08, 2010 5:03 pm

Dev... wat compiler do u use?

Naveen

Posts : 15
Points : 21
Join date : 2010-03-05
Age : 35

Back to top Go down

wat's the o/p of pgm?? Empty Re: wat's the o/p of pgm??

Post by Christopher Mon Mar 08, 2010 5:19 pm

check ur pgm. the following stmt ll throw u error when u try to compile it.

Code:
float f=5.5

by default decimal values are double in java. so if u want to initialize a float variable, u have to type cast it.

Code:
float f=5.5f;
or
float f=5.5F;
or
float f=(float)5.5;
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

wat's the o/p of pgm?? Empty Re: wat's the o/p of pgm??

Post by Naveen Mon Mar 08, 2010 5:33 pm

Yeaaa got it...

Naveen

Posts : 15
Points : 21
Join date : 2010-03-05
Age : 35

Back to top Go down

wat's the o/p of pgm?? Empty Re: wat's the o/p of pgm??

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum