google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: C++ program to find percentage of student using class student

Saturday, February 21, 2015

C++ program to find percentage of student using class student

 Write a C++ program to create a class Student which contains data members as Roll_Number, Stud_Name, Percentage.  Write member functions to accept Student information.  Display all details of student along with a class obtained depending on percentage. (Use array of objects)

#include<iostream.h>
#include<conio.h>
#include<string.h>
class student
{
    int rollno;
    char name[10];
    int no_of_sub;
    int marks_of_each_sub[10];
    float per,m1;
    public:
    student()
    {}
    student(int rno,char nm[],int no_sub)
    {
        rollno=rno;
        strcpy(name,nm);
        no_of_sub=no_sub;
        if(no_of_sub>0)
        {
        for(int i=0;i<no_of_sub;i++)
        {
        cout<<"enter the marks of subject:->";
        cin>>marks_of_each_sub[i];
        m1=m1+marks_of_each_sub[i];
        per=m1/no_of_sub;
        }
        }

    }
      void show()
      {
        cout<<"\n\t"<<rollno<<"\t"<<name<<"\t"<<no_of_sub<<"\t\t"<<per<<"\t";
        for(int i=0;i<no_of_sub;i++)
        {
        cout<<marks_of_each_sub[i];
        cout<<"\n\t\t\t\t\t\t";
        }
      }

};

void main()
{
   clrscr();
   student x[10];
   int rno,i,no;
   char nm[10];
   int no_sub;
   cout<<"\n\thow many no u want?";
   cin>>no;
   for(i=0;i<no;i++)
   {
    cout<<"\nenter the rno:->";
    cin>>rno;
    cout<<"\nenter the name:->";
    cin>>nm;
    cout<<"\nenter the no of subject:->";
    cin>>no_sub;
    x[i]=student( rno,nm,no_sub);
   }
   cout<<"\n\trollno"<<"\tname"<<"\tno_of_sub"<<"\tper"<<"\tmarks_of_each_sub";
   for(i=0;i<no;i++)
   {
    x[i].show();
   }
   getch();
}

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...