I need to calculate each students average grade : <pre><code>/*This code creates two text files : Mokiniai.txt and Vidurkiai.txt
In Mokiniai.txt there are stored each students grades, in Vidurkiai there
should be calculated each students average grade*/

#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;fstream&gt;
using namespace std;


int main()
{
    int n, k, isvisopazymiu, i, pazymiai;
    double vidurkis; //average grade
    ofstream myfile;
    myfile.open("Mokiniai.txt");
    cout &lt;&lt; "parasykite kiek mokiniu yra" &lt;&lt; endl; cin &gt;&gt; n; //how many students
    myfile &lt;&lt; n &lt;&lt; endl;
    cout &lt;&lt; "parasykite kiek yra mokiniu pazymiu"; cin &gt;&gt; isvisopazymiu; // how many grades one student has
    for (k = 1; k &lt;= n; k++) {
        for (i = 1; i &lt;= isvisopazymiu; i++) {
            cout &lt;&lt; "Parasykite kokie yra mokiniu pazymiai "; cin &gt;&gt; pazymiai; // what are students grades
            myfile &lt;&lt; " " &lt;&lt; pazymiai;
        }
        myfile &lt;&lt; endl;
    }
    myfile.close();
    myfile.open("Vidurkiai.txt"); //trying to calculate average students grades on different file
    for (k = 1; k &lt;= n; k++) {
        vidurkis = pazymiai / isvisopazymiu; //calculating students grades
        myfile &lt;&lt; k &lt;&lt; " " &lt;&lt; vidurkis &lt;&lt; endl;
    }
    myfile.close();
    return 0;
}
</code></pre>

<p>My problem is that: There is something wrong in vidurkiai.txt file, but I don't know what is wrong.</p>

<p>For example: first students grades are : 7 8 9 7 8, and average grade should be 7,8, but after coding it, in vidurkiai.txt file it shows, that average grade is 1.</p>
