Skip to content

Commit c28fbe5

Browse files
authored
Create Functions.cpp
1 parent fb5d0e7 commit c28fbe5

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

HackerRank/Functions.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
using namespace std;
4+
5+
6+
int max_of_four(int a, int b, int c, int d){
7+
int max;
8+
if(a>b && a>c && a>d){
9+
max=a;
10+
}
11+
else if(b>a && b>c && b>d){
12+
max=b;
13+
}
14+
else if(c>a && c>b && c>d){
15+
max=c;
16+
}
17+
else{
18+
max=d;
19+
}
20+
return max;
21+
}
22+
int main() {
23+
int a, b, c, d;
24+
scanf("%d %d %d %d", &a, &b, &c, &d);
25+
int ans = max_of_four(a, b, c, d);
26+
printf("%d", ans);
27+
28+
return 0;
29+
}

0 commit comments

Comments
 (0)