Software & Finance





Turbo C Simple Student Mark List Preparation





Here is Turbo 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 <conio.h>

#include <process.h>

#include <string.h>

 

#pragma pack(2)

typedef struct _CStudent

{

    char name[64];

    int marks[5];

    int total;

} CStudent;

 

static int m_nMaxStudents;

static CStudent m_studList[100];

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

 

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

{

      int i, pos = m_nMaxStudents;

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

      m_studList[pos].total = 0;

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

      {

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

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

      }

      m_nMaxStudents++;

}

 

void ViewRecords()

{

    int i = 0;

    printf("_______________________________________________________________\n");

    printf("SNo Student Name       Sub1   Sub2   Sub3   Sub4   Sub5   Total\n");

    printf("_______________________________________________________________\n");

 

    for(i = 0; i < m_nMaxStudents; i++)

    {

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

                i + 1,

                m_studList[i].name,

                m_studList[i].marks[0],

                m_studList[i].marks[1],

                m_studList[i].marks[2],

                m_studList[i].marks[3],

                m_studList[i].marks[4],

                m_studList[i].total);

    }

    printf("_______________________________________________________________\n");

}

 

 

void InputRecords()

{

      char name[64];

      int i, marks[5];

 

      printf("Student Name: ");    

      scanf("%s", name);

     

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

      {

          printf("Sub %d Mark:", i);

          scanf("%d", &marks[i-1]);

      }

      AddRecord(name, marks);

}

 

 

int main()

{

    int i, numStudents = -1;

   

    printf("Welcome to Student MarkList Application\n");

    printf("Enter the number of Students: ");

 

    scanf("%d", &numStudents);

 

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

    {

        printf("\n\nEnter the %d student information:\n", i + 1);

       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

_______________________________________________________________