Bizarre output in Visual C++
<p>Here's the code:</p>

<pre><code>// WAP to implement student result preparation.

#include "stdafx.h"
#include "iostream"
#include "conio.h"

using namespace std;

float total;
const int obj = 3;
const int size = 3;

class student
{
    int rollno;
    char name[20], grade;
    float marks[size], perc;
public:
    void getval()
    {
        cout &lt;&lt; "Enter roll number: ";
        cin &gt;&gt; rollno;
        cout &lt;&lt; "\nEnter student's name: ";
        cin &gt;&gt; name;
        cout &lt;&lt; "\nEnter student's physics marks: ";
        cin &gt;&gt; marks[0];
        cout &lt;&lt; "\nEnter student's chemistry marks: ";
        cin &gt;&gt; marks[1];
        cout &lt;&lt; "\nEnter student's mathematics' marks: ";
        cin &gt;&gt; marks [2];
        cout &lt;&lt; "\n";
    }
    void calculate()
    {
        perc = total / 3;
        if (perc &lt; 50)
            grade = 'F';
        else if (perc &gt;=50 &amp;&amp; perc &lt; 60)
            grade = 'D';
        else if (perc &gt;= 60 &amp;&amp; perc &lt; 75)
            grade = 'C';
        else if (perc &gt;= 75 &amp;&amp; perc &lt; 90)
            grade = 'B';
        else
            grade = 'A';
    }
    void prnresult()
    {
        cout &lt;&lt; "\nRoll number: " &lt;&lt; rollno;
        cout &lt;&lt; "\nName: " &lt;&lt; name;
        cout &lt;&lt; "\nTotal marks: " &lt;&lt; total;
        cout &lt;&lt; "\nPercentage: " &lt;&lt; perc;
        cout &lt;&lt; "\nGrade: " &lt;&lt; grade;
        cout &lt;&lt; "\n";
    }
};

student jk[obj];

int _tmain(int argc, _TCHAR* argv[])
{   
    for (int i = 0; i &lt; obj; i++)
    {   cout &lt;&lt; "Student " &lt;&lt; i + 1 &lt;&lt; "\n";
        jk[i].getval();
    }
    for (int j = 0; j &lt; obj; j++)
    {
        jk[j].calculate();
        cout &lt;&lt; "Result: ";
        jk[j].prnresult();
    }
    _getch();
    return 0;
}
</code></pre>

<p>This is a textbook program. The author says that it works perfectly in Turbo C++ (can you imagine? Something that was last updated in early 1990s!). But when I compiled this in Visual C++ 2010 Express, it doesn't calculate the total and percentage. It just shows zero. Any idea why this happens?</p>
