In: Computer Science
Write a C++ program to do the following USING ARRAYS
1) input 15 integers (input validation , all numbers must be between 0 and 100)
2) find the largest number
3) Find the Smallest Number
4) Find the Sum of all numbers in the Array
Display: as per the user's section (menu using switch or if else )
Largest Number
Smallest Number
Sum of all numbers
the original Array
DO NOT USE METHODS OR FUNCTIONS Submit: Source code (C++)
output (Word or pdf file)
Also include a while loop to repeat the program
#include<iostream>
using namespace std;
//main
int main()
{
    //array declaration
    int arr[15];
    cout<<"Enter 15 integers between 0 & 100:\n";
    //variables declaration
    int i=0,x,minn=100,maxx=0,sum=0;
    //while loop
    while(i<15)
    {
        cin>>x;
        //validate if the input is between 0 & 100
        if(x>0 && x<100)
        {
            arr[i]=x;
            if(x<minn)
                minn=x;   //smallest number
            if(x>maxx)
                maxx=x;   //largest number
            sum=sum+x;   //calculating sum
            i++;
        }
        else
        {
            cout<<"wrong input,try again...";  //in case of wrong input
        }
    }
    //printing results
    cout<<"Largest Number: "<<maxx<<endl;
    cout<<"Smallest Number: "<<minn<<endl;
    cout<<"Sum of all numbers: "<<sum<<endl;
    
    i=0;
    //printing array using while loop
    cout<<"Original Array: ";
    while(i<15)
    {
        cout<<arr[i]<<" ";
        i++;
    }
    return 0;
}
OUTPUT:
