Program of a class report

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#define s 5
class report
{
private:
int  adm_no;
char name[20];
float marks[s];
float avgm;
float getavg(float marks[]);
public:
void readinfo();
void displayinfo();
};
float report::getavg(float marks[])
{ float avg,sum;
avg=sum=0;
for(int i=0;i<s;i++)
{sum+=marks[i];
}
avg=sum/5;
return avg;
}
void report::readinfo()
{
  cout<<"enter the admission no";
  cin>>adm_no;
  cout<<"enter the name";
  gets(name);
  cout<<"enter the marks";
  for (int i=0;i<s;i++)
  {
   cin>>marks[i];}

   avgm=getavg(marks);}
  void report::displayinfo()
  {
   cout<<adm_no;
   puts(name);
   cout<<avgm;
  }
  void main()
  {
   report r1;
   r1.readinfo();
   r1.displayinfo();
   getch();
  }

Comments

Popular Posts