We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Introduction
- Functions
- Discussions
Functions
Functions
Sort by
recency
|
1962 Discussions
|
Please Login in order to post a comment
HERE'S A BASIC AND UNDERSTANDABLE APPROACH
include
include
include
using namespace std;
int max_of_four(int a, int b, int c, int d) { vector v1 = {a, b, c, d}; // Initialize vector int maxi = v1[0]; // Start with the first element
}
int main() { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); int ans = max_of_four(a, b, c, d); printf("%d", ans);
}
include
using namespace std;
int max_of_four(int a, int b, int c, int d){ int max= a>b ? a:b; if(c>max)max=c; return d>max ? d: max; } /* Add
int max_of_four(int a, int b, int c, int d)
here. */int main() { int a=3, b=4, c=6, d=5; cin>>a>>b>>c>>d;
}
Bros this code is also return the max value but they are not accepting this code int max_of_four(int a,int b,int c,int d){ if(a>b&&a>c&&a>d){ return a; } else if(b>a&&b>c&&b>d){ return b; } else if(c>a&&c>b&&c>d){ return c; } else{ return d; } }i