mini -max sum

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> int main() { //Initialize array int arr[10],n,sum=0; scanf("%d",&n); for (int i = 0; i < n; i++) scanf("%d",&arr[i]); int min = arr[0],max=arr[0]; //Loop through the array for (int i = 0; i < n; i++) { //Compare elements of array with min if(arr[i] < min) min = arr[i]; } printf("Smallest element present in given array: %d\n", min); for (int i = 0; i < n; i++) { //Compare elements of array with min if(arr[i] > max) max = arr[i]; } printf("Smallest element present in given array: %d\n", max); for (int i = 0; i < n; i++) sum=sum+arr[i]; printf("The minimum sum is %d",sum-max); printf("the maximum sum is %d",sum-min); }
Editor Settings
Theme
Key bindings
Full width
Lines