SOURCE CODE: #include<iostream.h> #include<conio.h> class Report { int sub[5]; float avg; public: void Add(); void Avg(); void Show(); }ob; void Report::Add() { cout<<"\n Enter the 5 subject marks: "; for(int i=0; i<5; i++) cin>>sub[i]; } void Report::Avg() { avg=0; for(int i=0; i<5; i++) avg+=sub[i]; avg/=5; } void Report::Show() { cout<<"\n The Average marks are: "<<avg; } void main() { clrscr(); ob.Add(); ob.Avg(); ob.Show(); getch(); }; OUTPUT: |
Sem 3 > OOPS (C++) LAB >