
LANGUAGE: JAVA
CHALLENGE:
Write the definition of a method printLarger, which has two int parameters and returns nothing. The method prints the larger value of the two parameters to standard output on a single line by itself.
SOLUTION:
public void printLarger (int aint, int bint){ System.out.println(Math.max(aint, bint)); }
Can you print this in C code? Thanks. Your answers are always very helpful.
for c
void printLarger(int a, int b)
{
if (a > b){
printf(“%d\n”, a);
}
else {
printf(“%d\n”, b);
}
}