New course! Every coder should learn Generative AI!
Try a free lesson0
i cant figure this out
Rearrange the code to declare a function taking two integer and one char parameters. If char's value is "+", return the sum of the integer arguments. Otherwise, return the product of their multiplication. return a * b; int foo(int a, int b, char c) { return a + b; } } if (c == '+') {
1 Answer
+ 3
int foo(int a, int b, char c) {
if (c == '+') {
return a + b; }
return a * b;
}
By default it will return a * b, unless c == '+'.