Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi guys use Basic programming only!! Thankyou Write a program to a sk the user a

ID: 674545 • Letter: H

Question

Hi guys use Basic programming only!! Thankyou          

Write a program to ask the user as to how many numbers they want to enter.

your program should collect that many numbers from the user and find the smallest and Average of those numbers.

For example, if the user says, he/she wants to enter 6 numbers, you should collect 6 numbers. You can accomplish this by looping 6 times, collecting one number each time you are in the loop.

Hint1: You can use the while..wend loop to write this program

Hint2: Study the program which calculates the largest of the 10 numbers

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

int n,number;

cout << "How many numbers you want to input ? ";

cin >> n;

  

int max = 0;

float avg = 0;

  

  

for(int i=0;i<n;i++)

{

cout << "Enter the number " << i+1 << " : ";

cin >> number;

  

if(i==0)

max = number;

else

{

if(max<number)

max = number;

}

avg = avg+number;

}

  

cout << "Largest number is : "<< max << endl;

cout << "Average of numbers is : " << avg/n;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote