Sem 3‎ > ‎OOPS (C++) LAB‎ > ‎

Q1. WAP, using classes, to get marks of 5 subjects and find average.

posted Jul 28, 2011, 8:28 AM by Neil Mathew   [ updated Jul 28, 2011, 9:17 AM ]

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:



Comments