program is supposed to count the average number, then put out the numbers that are below the average number. E.g: I insert 4, then I input 4 integers; 1 2 3 4 and it outputs 2, because the average number of 1 2 3 and 4 is 2.5 and there are 2 integers below 2.5
#include <iostream>
usingnamespace std;
int main()
{
float number = 0.0; // in case the user enters a decimal value
float avrg; // You will need the decimal precision, doens't need to be declared here
int input; //also doesn't need to be declared here
cout << "Enter how many values you are going to use: " << endl;
cin >> input;
float* arr = newfloat [input]; // to allow the user to enter a decimal value
cout << "Enter all the values consecutively: " << endl;
for(int i = 0; i < input; i++) // Loop for user to enter in all the values
{
cin >> arr[i];
number += arr[i];
/*if(arr[i] == 0)
{
arr[i]++;
}
*/
}
avrg = number / input;
for(int i = 0; i < input; i++) // Loops through arr[] and outputs if arr[i] is lower than avrg
{
if(arr[i] < avrg)
{
cout << "Under the average: " <<arr[i] << endl;
}
}
cout << "The average: " <<avrg << endl;
}
I made some changes however the comments should help you along the way, if you need any help feel free to PM me, good luck !