0
How to check which function is same or different
7 Answers
+ 1
Preity Show your attempt here.
+ 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
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
0
ā³AsterisKā³ I've tried and didn't get why foo2 and foo3 return same, that's why I've asked questions
0
On executing code only output is shown. Decoding the output is main thing which I'm not getting
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
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