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 in C
- Discussions
Functions in C
Functions in C
Sort by
recency
|
793 Discussions
|
Please Login in order to post a comment
include
/* C program to find max of four numbers */ int max_of_four(a,b,c,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; } }
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
/* Add
int max_of_four(int a, int b, int c, int d)
here. */int main() { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); int max; if(a>b&&a>c&&a>d) { max=a; } else if(b>a&&b>c&&b>d) { max=b; } else if(c>a&&c>b&&c>d) { max=c; } else{ max=d; }
}
include
/* Add
int max_of_four(int a, int b, int c, int d)
here. */ 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; } }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
int max_of_four(int a, int b, int c, int d) { int max; if(a>b && a>c && a>d) { max=a; } else if(b>a && b>c && b>d) { max=b; } else if (c>a && c>b && c>d) { max = c; } else { max=d; }
}
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
include
/* Add
int max_of_four(int a, int b, int c, int d)
here. */int max(int a,int b) { if(a>b) return a; else return b; } int main() { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); int ans=max(a,b); int ans1=max(c, d); int ans2=max(ans,ans1); printf("%d", ans2);
return 0; }