c++ - Finding the closest number of array to another given number -
i have program write have array of 11 numbers entered me. need find avarage sum of numbers, , im asked find closest number of array avarage sum, , distant element of array avarage sum again. far manage write program create array , find avarage sum. asssume there abs function of cmath libary , far fail make it.
#include <iostream> using namespace std; int main() { unsigned const int size = 11; float number[size]; (unsigned = 0; i<size; i++) { cout << "please enter value number " << + 1 << ":"; cin >> number[i]; } (unsigned = 0; i<size; i++) { cout << "number " << + 1 << " : " << number[i] << endl; } unsigned int sum = 0; (unsigned = 0; i<size; i++) { sum += number[i]; }
what problem? not asking question, making statement... seem have not posted whole code..
in c++ use "abs" should use fabs "math.h" library!
Comments
Post a Comment