Computer Science, asked by dhruvbandral, 2 days ago

Define a class student with the following specification private members :
roll no integer
name 40 characters
clas 8 characters
marks integer
percentage float
public members:
readmarks(). a function that read marks displaymarks A function that prints the marks​

Answers

Answered by zaabedeen10
0

Answer:

#include<iostream>

using namespace std;

class student

{

private:

int roll,m1,m2,m3,m4,m5; //m1,m2,m3,m4,m5 denoting marks

float p; //p is percentage here

char name[40],clas[8];

public:

void getinfo()

{

cout<<"Enter name : ";

cin>>name;

cout<<"Enter class : ";

cin>>clas;

cout<<"Enter roll no. : ";

cin>>roll;

}

void getmarks()

{

cout<<"Enter marks of 5 subjects : ";

cin>>m1>>m2>>m3>>m4>>m5;

p=1.0*(m1+m2+m3+m4+m5)*100/500*1.0;

}

void displaymarks()

{

cout<<"Marks are : "<<m1<<"\n"<<m2<<"\n"<<m3<<"\n"<<m4<<"\n"<<m5<<endl;

cout<<"Percentage is : "<<p<<endl;

}

};

int main()

{

student s;

s.getinfo();

s.getmarks();

s.displaymarks();

}

Similar questions