Advertisements
Advertisements
Question
Implement a class average that accepts. value of three float variables another function print() average of three numbers.
Code Writing
Advertisements
Solution
#include <iostream.h>
class average
{
private
float a, b, c, s;
Public:
average()
{
cout<<"Enter 3 nos.";
cin>>a>>b>>c;
}
void cal()
{
s = (a + b + c)/3;
}
void print()
{
cout<<"average="<<s;
}
~average() { }
};
void main()
{
average ob;
ob.cal();
ob.print();
}shaalaa.com
Is there an error in this question or solution?
