Question 4 || Hacker Rank
Functions in C || Hacker Rank
Objective
In this test, you will learn basic utilization of capabilities in C. Capabilities are a lot of assertions gathered together. A capability is given at least zero contentions, and it executes the assertions on it. In light of the return type, it doesn't either return anything (void) or something to that effect.
An example sentence structure for a capability is
return_type function_name(arg_type_1 arg_1, arg_type_2 arg_2, ...) {
...
...
...
[assuming that return_type is non void]
return something of type 'return_type';
}
For instance, a capability to peruse four factors and return the amount of them can be composed as
int sum_of_four(int a, int b, int c, int d) {
int total = 0;
total += a;
total += b;
total += c;
total += d;
bring total back;
}
+= : Add and task administrator. It adds the right operand to the left operand and allots the outcome to the left operand.
a += b is identical to a = a + b;
Task
Compose a capability int max_of_four(int a, int b, int c, int d) which peruses four contentions and returns the best of them.
Note
There isn't implicit max capability in C. Code that will be reused is many times placed in a different capability, for example int max(x, y) that profits the more prominent of the two qualities.
Input Organization
Information will contain four numbers - , one on each line.
Yield Arrangement
Print the best of the four numbers.
Note: I/O will be consequently taken care of.
Test Information
3
4
6
5
Test Result
6
0 Comments