Classes With Arrays As Data Members OOPS programming in c++ how to implement Classes with array

In these Source code algorithm it has class student and there fucniton get () and total(). It will get the data by through array from the user input for OOPS programming. CS 2209-object Oriented Programming
Source Code programming algorithm in c++ CS 2209
#include<iostream.h>
#include<conio.h>
class student
{
char name[30];
int m[5],i,sum;
float avg;
public:
void get();
void total();
void average();
};
void student::get()
{
cout<<"\nEnter a Name : ";
cin>>name;
cout<<"\nEnter the 5 marks : ";
for(i=0;i<5;i++)
{
cin>>m[i];
}
}
void student::total()
{
for(i=0;i<5;i++)
{
sum+=m[i];
}
cout<<"\nSum is "<<sum;
}
void student::average()
{
avg=sum/5;
cout<<"\nAverage is "<<avg;
}
void main()
{
clrscr();
student JJ;
JJ.get();
JJ.total();
JJ.average();
getch();
}
OUTPUT CS 2209 OOPS programming
Enter a Name : STUDENTWEBSITE
Enter the 5 marks :
100
99
95
80
100
Sum is 474
Average is 94.8

Post a Comment

0 Comments