#include "stdafx.h"
#include <iostream>
using namespace std;
void plus();
void minus();
void mult(); //Here are the declerations of the functions.
void dev();
void exit();
int main()
{
int sth=0;
while(1) //The while loop,will execute again and again the stuff below(but only code which is in it's scopes!)
{
cout << "Press 1 for Addition" << endl;
cout << "Press 2 for Subtraction" << endl ; //Here are the senteces about calculations..
cout << "Press 3 for Multiplication" << endl;
cout << "Press 4 for Devision" << endl ;
int choice;
cin >> choice;
switch (choice) //The switch statement,is like the if statement.It will run the cases below.
{
case 1:
choice = 1;
cout << "->Addition\n";
plus();
break;
case 2:
choice = 2;
cout << "->Subtraction\n";
minus();
break;
case 3:
choice = 3;
cout << "->Multiplication\n";
mult();
break;
case 4:
choice = 4;
cout << "->Devision\n";
dev();
break;
}
continue; //Here the loop will stop and run again from the beginning.
}
char f;
cin >> f;
return 0;
}
void plus() //Here are the function's definitions.
{
int my[2]; //The array here,will make 2 new integer variables,for later use.
cout << "Put 1st number: ";
cin >> my[0]; //Int the 1st array here will be put the 1st number.
cout << "Put 2nd number: " ;
cout << endl;
cin >> my[1]; //And here the 2nd.
cout << "The result is : ";
cout << my[0] + my[1] << endl; //This will print out the result.
exit(); //And at the end the "exit" function will be called!
}
void minus()
{
int my[2];
cout << "Put 1st number: ";
cin >> my[0];
cout << "Put 2nd number: " << endl ;
cin >> my[1];
cout << "The difference is : ";
cout << my[0] - my[1]<< endl ;
exit();
}
void mult()
{
int my[2];
cout << "Put 1st number: ";
cin >> my[0];
cout << "Put 2nd number: " << endl ;
cin >> my[1];
cout << "The product is : ";
cout << my[0] * my[1] << endl ;
exit();
}
void dev()
{
int my[2];
cout << "Put 1st number: ";
cin >> my[0];
cout << "Put 2nd number: " << endl ;
cin >> my[1];
cout << "The quotient is : ";
cout << my[0] / my[1] << endl;
exit();
}
void exit()
{
cout << " Press 0 to Exit" << endl ;
int quit;
cin >> quit;
if (quit == 0)
{
exit(0);
}
}
0 comments:
Post a Comment