0

How to check which function is same or different

https://www.sololearn.com/post/163137/?ref=app

22nd Oct 2019, 6:44 AM
Preity
Preity - avatar
7 Réponses
+ 1
Preity Show your attempt here.
22nd Oct 2019, 6:59 AM
A͢J
A͢J - avatar
+ 1
i expect all 3 to give the same output, because they are implicitly typecasted to integer, which means if you input 7.5 it will be 7/2 in all of the functions so not only 2&3
22nd Oct 2019, 7:00 AM
✳AsterisK✳
✳AsterisK✳ - avatar
0
why not try it out on a code and see for yourself, that will even help you better, than for someone to tell you the answer and explain it, the person who answered will improve alot and you little, but if you try it yourself you will learn alot and understand that better
22nd Oct 2019, 6:55 AM
✳AsterisK✳
✳AsterisK✳ - avatar
0
✳AsterisK✳ I've tried and didn't get why foo2 and foo3 return same, that's why I've asked questions
22nd Oct 2019, 6:58 AM
Preity
Preity - avatar
0
On executing code only output is shown. Decoding the output is main thing which I'm not getting
22nd Oct 2019, 6:59 AM
Preity
Preity - avatar
0
✳AsterisK✳ yeah I know that all 3 will return same but how implicit type conversion work as integer has low limit then float than how can it store float value
22nd Oct 2019, 7:28 AM
Preity
Preity - avatar
0
Here the code which return same but I want to know logic here is my try AJ || ANANT || AC || ANANY || AY #include <stdio.h> foo1(float a); foo2(double a); foo3(unsigned a); int foo1(float a){ int b =a; return b/2; } int foo2(double a){ int b =a; return b/2; } int foo3(unsigned a){ int b =a; return b/2; } int main() { int x,y,z, result1,result2, result3; x = 7; result1 = foo1(x); printf("%d foo1 is %d\n", x, result1); y = 7; result2 = foo2(y); printf("%d foo2 is %d\n", x, result2); z = 7; result3 = foo3(z); printf("%d foo3 is %d\n", x, result3); return 0; } How Type cast to integer is done
22nd Oct 2019, 7:29 AM
Preity
Preity - avatar