Software & Finance





Visual C++ Simple Student Mark List Preparation





Here is Visual C++ source code for simple Mark List Preparation . You can add student name and marks for 5 subjects. Then you can view the student mark list.

 

This Program is a simple version and will not persist any data and you can not modify any data. To get the advanced version which does menu oriented persistant data, view the following links:

 

 

See Also:


Source Code


#include <stdio.h>

#include <tchar.h>

#include <conio.h>

#include <process.h>

#include <dos.h>

#include <iostream>

#include <string.h>

 

#pragma pack(2)

struct CStudent

{

public:

    char name[64];

    int marks[5];

    int total;

};

 

struct CStudents

{

    #define MaxSz  100

    int m_nMaxStudents;

    CStudent m_studList[MaxSz];

    CStudents();

    void AddRecord(const char *name, int *marks);

};

 

CStudents::CStudents()

{

      m_nMaxStudents = 0;

}

 

void CStudents::AddRecord(const char *name, int *marks)

{

      int pos = m_nMaxStudents;

      strcpy(m_studList[pos].name,name);

      m_studList[pos].total = 0;

      for(int i = 0; i < 5; i++)

      {

            m_studList[pos].marks[i] = marks[i];

            m_studList[pos].total += marks[i];;

      }

      m_nMaxStudents++;

}

 

CStudents theStudents;

 

void ViewRecords()

{

    std::cout << "_______________________________________________________________\n";

    std::cout << "SNo Student Name       Sub1   Sub2   Sub3   Sub4   Sub5   Total\n";

    std::cout << "_______________________________________________________________\n";

 

    for(int i = 0; i < theStudents.m_nMaxStudents; i++)

    {

        printf("%3d %-19s %-6d %-6d %-6d %-6d %-6d %-6d\n",

                i + 1,

                theStudents.m_studList[i].name,

                theStudents.m_studList[i].marks[0],

                theStudents.m_studList[i].marks[1],

                theStudents.m_studList[i].marks[2],

                theStudents.m_studList[i].marks[3],

                theStudents.m_studList[i].marks[4],

                theStudents.m_studList[i].total);

    }

    std::cout << "_______________________________________________________________\n";

}

 

 

void InputRecords()

{

      char name[64];

      int marks[5];

 

      std::cout << "Student Name: ";    

      std::cin >> name;

     

      for(int i = 1; i <= 5; i++)

      {

        std::cout << "Sub " << i << " Mark: ";

        std::cin >> marks[i-1];

      }

      theStudents.AddRecord(name, marks);

}

 

 

int main()

{

    ::system("cls");

    std::cout << "Welcome to Student MarkList Application\n";

    std::cout << "Enter the number of Students: ";

 

    int numStudents = -1;

    std::cin >> numStudents;

 

    for(int i = 0; i < numStudents; i++)

    {

        std::cout << "\n\nEnter the " << i + 1 << " student information:\n";

       InputRecords();

    }

    ViewRecords();

    getch();

}

 

Output


Welcome to Student MarkList Application

Enter the number of Students: 3

 

 

Enter the 1 student information:

Student Name: AAA

Sub 1 Mark:40

Sub 2 Mark:50

Sub 3 Mark:60

Sub 4 Mark:70

Sub 5 Mark:80

 

 

Enter the 2 student information:

Student Name: BBB

Sub 1 Mark:80

Sub 2 Mark:80

Sub 3 Mark:70

Sub 4 Mark:670

Sub 5 Mark:90

 

 

Enter the 3 student information:

Student Name: CCC

Sub 1 Mark:100

Sub 2 Mark:90

Sub 3 Mark:99

Sub 4 Mark:88

Sub 5 Mark:89

_______________________________________________________________

SNo Student Name       Sub1   Sub2   Sub3   Sub4   Sub5   Total

_______________________________________________________________

  1 AAA                 40     50     60     70     80     300

  2 BBB                 80     80     70     670    90     990

  3 CCC                 100    90     99     88     89     466

_______________________________________________________________