New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Brain & Bones
It’s a question on implicit conversion and compilation errors. That’s why the functions are named the same.
void f(int a, int b) {
return a + b;
}
Error - returning a value when return type is void.
int f(double a, double b) {
return a + b;
}
Type conversion - float returned as int.
int f(int a, int b) {
return a + b;
}
No implicit conversion or compilation errors.
long long f(int a, int b) {
return a + b;
}
Type conversion - int returned as long long.
void f(int a, int b) {
int c = a + b;
return;
}
No implicit conversion or compilation errors. Albiet useless.
+ 1
i think 2nd and 4th should be correct
0
Void functions should not contain ‘return’
And you cannot name all the functions the same thing.