Question

In: Computer Science

Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation...

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

Solutions

Expert Solution

#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:


Related Solutions

Write a Java program to do the following USING ARRAYS 1) input 15 integers (input validation,...
Write a Java 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: Largest Number Smallest Number Sum of all numbers the original Array DO NOT USE METHODS OR FUNCTIONS
Using Dev-C++ write a program that allows a small business owner to input, in parallel arrays,...
Using Dev-C++ write a program that allows a small business owner to input, in parallel arrays, the type of item, its cost, and the number in stock. The program should output this information in the form of a table. The output will look something like below. Also, assume for a finite number of item name of 3 Item Name Cost Number in Stock Widget 25.00 4 ... ... ... Wombet 47.50 9 Prelude to Programming (6th edition)
using c++ 10. Sorting Orders Write a program that uses two identical arrays of eight integers....
using c++ 10. Sorting Orders Write a program that uses two identical arrays of eight integers. It should display the contents of the first array, then call a function to sort it using an ascending order bubble sort, modified to print out the array contents after each pass of the sort. Next the program should display the contents of the second array, then call a function to sort it using an ascending order selection sort, modified to print out the...
In C++, write a program that uses two identical arrays of ten randomly ordered integers. It...
In C++, write a program that uses two identical arrays of ten randomly ordered integers. It should display the contents of the first array, then call a function to sort it using the most efficient descending order bubble sort, modified to print out the array contents after each pass of the sort. Next the program should display the contents of the second array, then call a function to sort it using descending order selection sort, modified to print out the...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three random integers in the range [1, 100] and continues as follows: If the right-most digit of all the three integers is equal, the program displays them in ascending order on the screen and continues. If the generated integers have different right-most digits, they are not displayed and the program continues. The program terminates once the right-most digits of all the three random numbers are...
c program Write a program that asks the user to enter a sequence of 15 integers,...
c program Write a program that asks the user to enter a sequence of 15 integers, each either being 0, 1, or 2, and then prints the number of times the user has entered a "2" immediately following a "1". Arrays are not allowed to appear in your code. Include ONLY THE SCREENSHOT OF YOUR CODE in an image file and submit the file.
Objective: Write this program in the C programming language Loops with input, strings, arrays, and output....
Objective: Write this program in the C programming language Loops with input, strings, arrays, and output. Assignment: It’s an organization that accepts used books and then sells them a couple of times a year at book sale events. Some way was needed to keep track of the inventory. You’ll want two parallel arrays: one to keep track of book titles, and one to keep track of the prices. Assume there will be no more than 10 books. Assume no more...
Write a program of Binary Search in C++ by using function and arrays with the explanation.
Write a program of Binary Search in C++ by using function and arrays with the explanation.
Write a program in c++ using only while and for loops . Use of arrays and...
Write a program in c++ using only while and for loops . Use of arrays and functions is not allowed. Given the first value, generate the next ten terms of the sequence like 1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, … Explaination with code is required.
Write a program in C# for a Cricket match using Jagged Arrays. The name of the...
Write a program in C# for a Cricket match using Jagged Arrays. The name of the project will be on your name. It has the following modules: Create two functions in class Cricket_Match for random numbers generation. The first function generates 1-6 numbers which is known as balls played by each player. The second function generates a 0-6 number which is known as the score produced against each ball by an individual player. In the main show the individual player...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT