Students Mark Lists Program In C++

What we are going to see through this article is we will see in detail the Students Mark Lists Program In C++. Databases are currently used in every aspect of our lives. Trillions of bytes of data are stored on servers around the world. One of the most basic methods for using such a database is SQL. But have you ever thought about using C ++ to maintain such a database?

In this program, we will calculate student quality. We will first start by announcing the required variables. Next, we will instruct the user to enter the object numbers. Then we will find out the quality of that student.

Students Mark Lists Program In C++

Students Mark Lists Program in C++

#include<iostream>
#include<string.h>
using namespace std;

class student
{
        int rollno, no_of_subjects;
        char stud_name[20];
        int *marks;
    public:
        student(int rno,char *name, int nos)        //Parameterized Constructor
        {
                rollno=rno;
                strcpy(stud_name, name);
                no_of_subjects=nos;
                marks=new int[no_of_subjects];   //dynamically memory allocated for storing marks
        }
        void accept();
        void display();
};
void student::accept()
{
        for(int i=0; i<no_of_subjects; i++)
        {
                cout<<"\n\n Enter Marks for Subject "<<i+1<<"  :  ";
                cin>>marks[i];
        }
}
void student::display()
{
        cout<<"\n -----------------------------------------";
        cout<<"\n\n Student Information";
        cout<<"\n -----------------------------------------";
        cout<<"\n\n Roll no             :  "<<rollno;
        cout<<"\n\n Name                :  "<<stud_name;
        for(int i=0; i<no_of_subjects; i++)
        {
                cout<<"\n\n Marks of Subject "<<i+1<<"  :  "<<marks[i];
        }
        cout<<"\n -----------------------------------------\n";
}
int main()
{
        int rollno, no_of_subjects;
        char stud_name[20];
        int cnt, i;
        cout<<"\n Enter No. of Students You Want? : ";
        cin>>cnt;
        for(i=0; i<cnt; i++)
        {
                cout<<"\n -----------------------------------------\n";
                cout<<"\n Enter Roll No           :   ";
                cin>>rollno;
                cout<<"\n Enter Name              :   ";
                cin>>stud_name;
                cout<<"\n Enter No. of Subjects   :   ";
                cin>>no_of_subjects;
                cout<<"\n -----------------------------------------";
                student st(rollno, stud_name, no_of_subjects);
                st.accept();
                st.display();
        }
        return 0;
}

Output

This is an example printed output mark list for two students.

Students Mark Lists Program in C++ pic
Students Mark Lists Program in C++ pic

Read Also: C++ Program To Print Hello World!

Final Words

What we learned through this article is Students Mark Lists Program In C++. Also if you have any doubts please leave a comment via the comment box. And we ask that you benefit everyone who shared this article with your friends.

Leave a Comment