Say I get the input from a user of how many arguements they want to enter: cin>>int num;
Then, I want to create an array with (num) slots in it. This is what I have, but it doesn't work. Everything else is the rest of my program, which, suprisingly, doesn't work (or generates more errors). I want to eventually build something which will calculate standard deviation for you, but I can't even get past the first part, finding the average.
Code:#include <iostream.h> double temp; int main() { double num; cin>>num; float arguments[num]; for (int i=0; i<=num; i++) { cout<<"Enter data member number "<<i<<"-> "; cin>>arguements[i]; double temp =+ arguements[i]; } double mean = temp / num; return 0; }
Gets:
--------------------Configuration: deviationcpp - Win32 Debug--------------------
Compiling...
deviationcpp.cpp
C:\My Documents\C++\Deviation\deviationcpp.cpp(9) : error C2057: expected constant expression
C:\My Documents\C++\Deviation\deviationcpp.cpp(9) : error C2466: cannot allocate an array of constant size 0
C:\My Documents\C++\Deviation\deviationcpp.cpp(9) : error C2133: 'arguments' : unknown size
C:\My Documents\C++\Deviation\deviationcpp.cpp(13) : error C2065: 'arguements' : undeclared identifier
C:\My Documents\C++\Deviation\deviationcpp.cpp(13) : error C2109: subscript requires array or pointer type
C:\My Documents\C++\Deviation\deviationcpp.cpp(13) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
C:\My Documents\C++\Deviation\deviationcpp.cpp(14) : error C2109: subscript requires array or pointer type
Error executing cl.exe.
deviationcpp.obj - 7 error(s), 0 warning(s)