printing marksheet program in C++

Following program made in Turbo C++ so if you are try different plateform show it give some syntax error, architecture/logic is same.

Here on this page, we made a program of printing a student mark sheet in C++. it is a demonstration of a printout related task i.e, printing receipt, printing Bill record etc.

In this program, only 5 subject names and subject marks (with their practicals subject) will be stored for which an array is used in the program. But, if there is no practical subject with any subject, in such a case, enter 0 value when the program asks for the practical subject name.

In this way, this program can be print the mark sheet of almost all the students who have 5 subjects whether practical subject available or not.

Before starting the program of Printing a Student Marksheet in C++, the header files and their functions used in the program are described below.

#include<iostream.h>
#include<fstream.h>
#include <stdio.h> //rename(),remove()
#include <stdlib.h> //itoa(),atoi()
#include<conio.h>
#include<dos.h> //getdate()
#include<iomanip.h> // setwidth(),setiosflags()
#include<string.h> //strupr(),strcpy(),strcmp() strcat()
 class student
 {
   int marks[5],marks2[5],total_marks,pr;
   char r_no[10],stu_name[20],dob[20],f_name[20],m_name[20];
   typedef char subj[100];
   subj name[20]; // store subject name into name[] array
  public:
   void get_record(void); // take personal and subject detail from user
   void printing(); // print marksheet
   void grade(int,int); // store subject grade
//convert digit into character form//
    void get_total(int); //
    void one(char[],int); //
    void two(int); //
    void three(char[],int,int); //
    void process(char[],int,int); //
};

Following Part of this Program will store subject detail (Theoretical marks and Practical marks). marks[j] for Theoretical marks and marks2[j] for Practical marks

cout<<"Student subject Detail/n (If prectical subject not then enter 0n";
 
for(int i=0;i<5;i++)
 {
   cout<<"Enter "<<i+1<<" subject name: ";
   gets(name[i]); // store subject
 }
 cout<<endl;
 for(int j=0;j<5;j++)
 {
    cout<<"nEnter "<<j+1<<" Subject marks : ";
    cin>>marks[j];  // store theory subject marks
    cout<<"And Practical marks : ";
    cin>>marks2[j];     // store practical subject marks
    total_marks=total_marks+marks[j]+marks2[j]; // calculate total marks of subject
 }
 pr = total_marks/5; // variable pr store percantage

To Print student mark sheet we write a file with each information entered by the user, using << operator. Here while- the loop will be executed 5 times(Because of 5 subjects).

int subject=0;
while(subject<5) // loop execute 5 time because of 5 subject
{
  fout<<"nt| ";
  fout.width(25);
  fout<<setiosflags(ios::left);
  fout<<strupr(name[subject]);// convert subject name into uppper case than write into file
  fout.width(6);
  fout<<setiosflags(ios::right);
  fout<<"|";
  fout.width(6);
  fout<<setiosflags(ios::right);
  fout<<marks[subject]; //print subject marks
  fout.width(5);
  fout<<setiosflags(ios::right);
  fout<<"|";
  fout.width(7);
  fout<<setiosflags(ios::right);
  if(marks2[subject]==0) // check subject is prectical or not
     fout<<"_";
  else
     fout<<marks2[subject];
  fout.width(5);
  fout<<setiosflags(ios::right);
  fout<<"|";
  fout.width(6);
  fout<<setiosflags(ios::right);
  fout<<marks[subject]+marks2[subject]; // print total of theory and prectical
  fout.width(4);
  fout<<setiosflags(ios::right);
  fout<<"|";
  fout<<" ";
  fout.width(13);
  fout<<setiosflags(ios::left);
  get_total(marks[subject]+marks2[subject]); // convert total into character form
  char ch[50];
  ifstream f0("char");
  while(!f0.eof()) {
     f0.getline(ch,50);
  } f0.close();
  strupr(ch); // convert string into upper case
  fout<<ch; // write total as character form into file
  remove("char"); // now remove char file after use
  fout<<" ";
  fout.width(3);
  fout<<setiosflags(ios::left);
  fout<<"|";
  grade(marks[subject],marks2[subject]);
  char g1[10];
  ifstream o1("grade");//open grade file to calculate grade for subject
  while(!o1.eof()) {
     o1.getline(g1,10);
    }o1.close();
  fout<<g1; // write grade into subject
  fout.width(4);
  fout<<setiosflags(ios::right);
  fout<<"|";
  if(subject==0)// represent row 
   {
     fout.width(8);
     fout<<setiosflags(ios::right);
     fout<<total_marks<<" |"; // print total subject marks accessing from get_record() function
   }
  if(subject==1)
  {
     fout.width(8);
     fout<<setiosflags(ios::right);
     if(marks[subject]<33||marks2[subject]) // check sudent passed or not
       fout<<"FAIL";
     else
       fout<<"PASSED";
     fout.width(4);
     fout<<setiosflags(ios::right);
     fout<<"|";
   }
  if(subject==2)
  {
     fout.width(7);
     fout<<setiosflags(ios::right);
     fout<<pr<<"%";
     fout.width(4);
     fout<<setiosflags(ios::right);
     fout<<"|";
  }
  if(subject==3)
  {
// write division into file
     fout.width(8);
     fout<<setiosflags(ios::right);
     if(pr>=60)
        fout<<"FIRST";
     else if(pr>=45&&pr<60)
        fout<<"SECOND";
     else if(pr<33)
        fout<<"THIRD";
     fout.width(4);
     fout<<setiosflags(ios::right);
     fout<<"|";
  }
  if(subject==4)
  {
     fout<<" DIV. |";
  }

The data entered by the user is in any form (lowercase or uppercase), the data in the file will be written in uppercase itself (because of strupr() function) as shown in the output.

Here to two execution show, the ability of the codes that can generate two different classes (12th and IT courses)  marks sheet.

OUTPUT

1st execution

 Student personal detail
Enter Class or Level   : 12th
 Enter Student roll no  : 1002
 Enter Student Name   : anand bisht	
 Enter Date of Birth     : 30/06/1996
 Enter Father Name     : kishan singh
 Enter Mother Name    : kamla devi

Student subject Detail
If prectical subject not then enter 0
Enter 1 subject name: hindi
Enter 2 subject name: english
Enter 3 subject name: biology
Enter 4 subject name: physics
Enter 5 subject name: chemistry

Enter 1 subject marks: 70
And Practical Marks  : 0
Enter 2 subject marks: 28
And Practical Marks  : 0
Enter 3 subject marks: 50
And Practical Marks  : 28
Enter 4 subject marks: 39
And Practical Marks  : 20
Enter 5 subject marks: 46
And Practical Marks  : 26

Marksheet will Generate as follows,

 

2nd Execution

Different Student Detail (different class) entering in the same way as above while Printed mark sheet is quite Different,

Thus, This Program can Printable to generate all mark sheet who Only 5 Subject.

 

video Demonstration:

Download complete Program and execute yourself, DOWNLOAD 

: in some cases setw() function can misbehave in that replace this from "/t".

Related Projects in C++ are:


C++ Examples

Like it?
Exit mobile version