हिंदी

Implement a class average that accepts. value of three float variables another function print() average of three numbers. - Computer Science 1

Advertisements
Advertisements

प्रश्न

Implement a class average that accepts. value of three float variables another function print() average of three numbers.

कोड लेखन
Advertisements

उत्तर

#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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2022-2023 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×