im a big c++ noob and I need help starting out a block of code for my program : <p>so i am making a code that takes data from a txt file and gets its variance.
The formula that my teacher required us to use needs the program to square the decimals in the txt file and then gets its sum. unfortunately i do not have a sample of code because I do not know where to start. I was only able to store the data in the text file into a vector.</p>

<pre><code>ifstream dataInput("D:\\Users\\Rodolfo Obre\\Documents\\Ateneo De Manila\\Intersession 2019\\Engg 21\\Programs\\Text Files\\Data Set.txt");
double readNumber;
vector&lt;double&gt; dataSet;

if (!dataInput.is_open()) {
    cerr &lt;&lt; "The file can not be opened\n";
    exit(1);//exits the program
}

while (dataInput &gt;&gt; readNumber){
        dataSet.push_back(readNumber);
}
cout &lt;&lt; "n is equal to " &lt;&lt; dataSet.size() &lt;&lt; endl;

double sum=0;
for (int i=0; i &lt; dataSet.size(); i++){
    sum += dataSet[i];
}
cout &lt;&lt; "The sum of the data is " &lt;&lt; sum &lt;&lt; endl;
</code></pre>

<p>This block of code takes the data from the txt file, counts how many there are and then takes its sum.</p>

<p>I have no idea how I to do the part where i need to take each decimal in the text file, raise it to the power 2 and then get the sum of all of the values.</p>
