#include <iostream>
class Marks
{
public:
void set_marcs()
{
std::cout << "Enter your first mark: ";
std::cin >> mark_1;
std::cout << "Enter your second mark: ";
std::cin >> mark_2;
std::cout << "Enter your third mark: ";
std::cin >> mark_3;
}
int sum()
{
return mark_1 + mark_2 + mark_3;
}
double avg()
{
return sum() / 3.0;
}
private:
int mark_1{ 0 };
int mark_2{ 0 };
int mark_3{ 0 };
};
int main()
{
Marks example;
example.set_marcs();
std::cout << "Sum of marks: "<<example.sum()<<std::endl;
std::cout << "Average of marks : " << example.avg() << std::endl;
return 0;
}
Comments
Leave a comment