Hello, Im a beginner at C++ and I have completely lost my mind to what my instructor is asking.
The question is to create a program that finds the mean and standard deviation of up to 100 numbers. I got the equation down (below) now I need to extend it...and that is where my brain shut down.
Can I have some help?
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x1, x2, x3, x4, x5;
int X1, X2, X3, X4, X5;
int x;
int s;
You want to ask the user how many numbers they want to enter, then write a loop that
iterates that many times. Inside the loop, ask the user to enter 1 number, read it,
and process it.
You don't need two arrays/vectors.
Just modify the vector in place with for (n...) v[n] -= x;
Next sum the squares (use your s variable, but make it a double instead of an int ... you'll need a for loop for this too) and get the sqrt() of the result...
Are you kidding me?!? ARRAYS are also evil? Hmm... I guess I can see why.
Though seriously, Duoas, c'mon. Arrays may be evil in that sense, but in most C++ classes, as far as I know, you learn how to use them before you learn how to use vectors. Wonder why, though, vectors are superior to arrays in almost all aspects.
Provided that the OP is willing to learn about vectors: