Friday, 5 February 2021

Program to find sum of 2 numbers using class in C++.

 #include<iostream>

using namespace std;

class Sum

{

    public:

    int a,b,c;

    

    void input()

    {

        cout<<"Enter 2 Numbers\n";

        cin>>a>>b;

    }

    

    void Calculate()

    {

        c=a+b;

    }

    

    void Display()

    {

        cout<<"Sum = "<<c;

    }

};

    main()

    {

        Sum obj;

        obj.input();

        obj.Calculate();

        obj. Display();

    }

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...