| | |
Determin the average of an array that generates 30 random numbers.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Add them to a sum using a loop, then divide by 30. That's generally how one would find the average of a list of numbers:
C++ Syntax (Toggle Plain Text)
double sum = 0; for ( int i = 0; i < 30; i++ ) sum += a[i]; cout<<"Average: "<< sum / 30 <<'\n';
I'm here to prove you wrong.
![]() |
Similar Threads
- Help needed filling array with unique random numbers (C++)
- C++ Random Numbers (C++)
- Random Numbers (C)
- not getting non repeating random numbers many times (C)
- Trying to find a better way to generate random numbers in Dev Pascal (Pascal and Delphi)
Other Threads in the C++ Forum
- Previous Thread: Program runs but not visible
- Next Thread: I need some help with basic C++
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






