C++ LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART- B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

old

PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 . . .

Write a c++ program to find the result of a student using class concept

 
 

 #include < iostream.h >
#include < conio.h >

class student
{
               int roll_no;
               char name[20];
               char class_st[8];
               int marks[5];
               float percentage;
               float calculate();
               public:
               void readmarks();
               void displaymarks();
};


float student::result()
{
               percentage=0;
               for(int i=0;i < 5;i++)
                percentage+=marks[i];
               percentage=(percentage/5);
               return percentage;
}


void student::getdata()
{
               cout << "Enter the roll no =";
               cin >> roll_no;
               cout<< "Enter the name:";
               cin >> name;
               cout<< "Enter the class studing in:";
               cin >> class_st;
               cout<< "Enter the marks:"<< endl;
               for(int j=0;j< 5;j++){
                              cout << "\tEnter mark "<< j+1 << ":";
                              cin >> marks[j];
               }
}



void student::showdata()
{
               cout << "Roll no:" << roll_no << endl;
               cout << "Name:" << name < < endl;
               cout << "Class:" <<  class_st << endl;
               cout << "Percentage:" << result()<< endl;
}

int main()
{
               student s1;
               s1.getdata();
               s1.showdata();
               return 0;
}