Saturday, October 12, 2019

Basic Calculator Program in C++

A simple calculator program that I wrote using C++ as my programming language that can perform basic arithmetic operations like addition, subtraction, multiplication and division.

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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

 




Sample Program Output


Program Listing

// calculator.cpp
// Author : Jake Rodriguez Pomperada,MAED-IT
// Date   : October 12, 2019  8:07 AM Saturday

#include <iostream>

using namespace std;

int val1=0,val2=0;
int sum=0,subtract=0,multiply=0, division=0;
char opt;

int main() {
   cout <<"\n\n";
   cout << "\tBasic Calculator in C++";
   cout <<"\n\n";
   cout << "\tEx. 3+4, 4-2, 5 * 3, 10 /2 ";
   cout <<"\n\n";
   cout <<"\tGive an expression : ";
   cin >> val1 >> opt >> val2;
   cout <<"\n";
   if (opt =='+') {
      sum = (val1+val2);
  cout <<"\tThe sum of " << val1
  << " and " << val2 << " is "
  << sum << ".";
  }

 else if (opt =='-') {
      subtract = (val1-val2);
  cout <<"\tThe difference of " << val1
  << " and " << val2 << " is "
  << subtract << ".";
}
else if (opt =='*') {
      multiply = (val1*val2);
  cout <<"\tThe product of " << val1
  << " and " << val2 << " is "
  << multiply << ".";
  }
else if (opt =='/') {
      division = (val1/val2);
  cout <<"\tThe quotient of " << val1
  << " and " << val2 << " is "
  << division << ".";
  }
   cout <<"\n\n";
   cout <<"\tEnd of Program";      
}







No comments:

Post a Comment