Answer:
following are the program to this question:
#include <iostream> //defining header file
using namespace std;
int main() //defining main method
{
int arr[10],n,sum=0,i; //defining integer variable
float avg; //defining float variable
cout<<"Enter total elements you want to insert in array: "; //print message
cin>>n; //input value
cout<<"Enter numbers: "; //print message
for(i=0;i<n;i++) //define loop to input value from user
{
cin>>arr[i]; //input values
}
for(i=0;i<n;i++) //defining loop for calculate average
{
sum=sum+arr[i]; //add number
avg=sum/n; // calculate average and holds its value
}
cout<< "Average number: "<<avg; //print average
for(i = 0;i < n; i++)//defining loop to find largest value
{
if(arr[0] < arr[i]) // check condition for largest number
{
arr[0] = arr[i]; //find number and store its value
}
}
cout << endl<<"Largest element = " << arr[0]; //print its value
return 0;
}
Output:
Enter total elements you want to insert in array: 5
Enter numbers: 10
20
0
5
1
Average number: 7
Largest element = 20
Step-by-step explanation:
In the given question is incomplete, in this question, we input an array and prints its average and largest number, which can be defined as follows:
- Defining an array, that is "arr" in this array input values from the user end.
- In the next two for loop is declared, the first loop uses integer and float variable, that is "sum and avg", the sum variable adds all array element and the avg variable calculate its average value.
- In the next for loop, the if block is used, that calculates its largest number and prints its value.