Problem 40

2 comments on “Problem 40”


  • sakshi

    code in CPP :
    #include
    #include
    using namespace std;
    int main()
    {
    int arr[5];
    int sum_max=0,sum_min=0;
    int max,min;
    for(int i=0; i>arr[i];
    for(int i=0; i<5; i++)
    cout<<arr[i]<<" ";
    max=INT_MIN;
    min=INT_MAX;
    for(int i=0; imax)
    max=arr[i];
    }
    for(int i=0; i<5; i++)
    {
    if(arr[i]!=max)
    sum_min=sum_min+arr[i];
    }
    cout<<"\nsum of 4 smalllest is: "<<sum_min;

    for(int i=0; i<5; i++)
    {
    if(arr[i]<min)
    min=arr[i];
    }
    for(int i=0; i<5; i++)
    {
    if(arr[i]!=min)
    sum_max=sum_max+arr[i];
    }
    cout<<"\nsum of 4 largest is: "<<sum_max;
    return 0;
    }