050305.cpp: Defines the entry point of the console application.
//
050304.cpp: Defines the entry point of the console application.
//
Arithmetic
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
using namespace Std;
void Add ()
{
printf ("Enter the Addend to be computed (e.g. a b) \ n");
int adda=0, addb=0,addc=0;
Cin >> Adda;
Cin >> ADDB;
ADDC = ADDA+ADDB;
cout <<adda<< "plus" <<addb<< "equals" << addc << Endl;
}
void Substraction ()
{
printf ("Enter the meiosis to be computed (e.g. a b) \ n");
int Suba = 0, Subb = 0, subc = 0;
Cin >> Suba;
Cin >> Subb;
SUBC = Suba-subb;
cout <<suba<< "minus" <<subb<< "equals" << subc << Endl;
}
void multiplication ()
{
printf ("Enter the multiplier to be computed (e.g. a b) \ n");
int Mula = 0, mulb = 0, Mulc = 0;
Cin >> Mula;
Cin >> Mulb;
MULC = mula*mulb;
cout <<mula<< "Multiply" <<mulb<< "equals" << mulc << Endl;
}
void Division ()
{
printf ("Enter the divisor to be computed (e.g. a b) \ n");
int DSA = 0, DSB = 0, DSC = 0,dsd=0;
CIN >> DSA;
CIN >> DSB;
DSC = DSA/DSB;
DSD = DSA%DSB;
cout <<dsa<< "except" <<dsb<< "equals" << DSC << "remainder" <<dsd<<endl;
}
void operation ()//Arithmetic function
{
printf ("Input data choose to do that operation \ n");
printf ("Input 0 opt out, 1 do addition, 2 do subtraction, 3 do multiplication, 4 do division (preserve remainder) \ n");
int operatione = 0;
Cin >> Operatione;
cout << Endl;
Try
{
if (Operatione = = 1)
{
Addition
Add ();
}
else if (Operatione = = 2)
{
Subtraction
Substraction ();
}
else if (Operatione = = 3)
{
Multiplication
Multiplication ();
}
else if (Operatione = = 4)
{
Let's go
Division ();
}
else if (Operatione = = 0)
{
Exit (0);
}
Else
{
Throw 1;
}
}
catch (int i)
{
cout << "Input error" << Endl;
}
Operation ();
}
int main ()
{
printf ("Welcome to use this calculator");
Operation ();
return 0;
}
Technical exchange [email protected]
Or come to me another blog exchange: http://www.oschina.net/code/snippet_2743162_55878
Or: http://blog.csdn.net/schopenhauerzhang/article/details/51308392
Welcome to my mailbox or blog messages, technical exchanges; [Email protected]
Write a simple calculator program in C + +