Saturday, October 24, 2020

Addition and Subtraction of Another Number in C++

 I wrote this program as a request of one of my subscriber in my youtube channel. This program that will ask the user to give two numbers and then the program will compute the sum of the two numbers. After which the program display two options to add and to substract the sum of two number by given a number value using if else statement in C++.  

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.


Program Listing

// addition_subtraction.cpp
// Jake Rodriguez Pomperada, MAED-IT, MIT
// www.jakerpomperada.blogspot.com / www.jakerpomperada.com
// jakerpomperada@gmail.com
// Bacolod City, Negros Occidental Philippines

#include <iostream>

using namespace std;

int main()
{
    int a=0,b=0,sum=0,difference=0;
    int option=0,add=0,subtract=0;
    int total=0;

    cout <<"\n";
    cout <<"\tAddition and Subtraction of Another Number in C++";
    cout <<"\n\n";
    cout <<"\tGive First  Value : ";
    cin >> a;
    cout <<"\tGive Second Value : ";
    cin >> b;

    sum = (a+b);
    difference = (a-b);

    cout <<"\n\n";
    cout << "\tThe sum of " << a << " and " << b <<
         " is " << sum <<"."<<"\n";

    cout <<"\n\n";
    cout << "\tOption  [1] - Add  [2] Subtract : ";
    cin >> option;
    cout <<"\n\n";
    if (option == 1) {
        cout << "\tGive a Number To Add     : ";
        cin >>add;
        total = add+ sum;
    }
    else if (option == 2) {
        cout << "\tGive a Number To Subtract : ";
        cin >>subtract;
        total = sum - subtract;

    }
    cout <<"\n\n";
    cout << "\tThe total result is " << total <<".";
    cout <<"\n\n";
    cout <<"\tEnd of Program";
    cout <<"\n";
}




No comments:

Post a Comment