Cod: Selectaţi tot
#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>Addition\n";
plus();
break;
case 2:
choice = 2;
cout <<Subtraction>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>> 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>> 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>> 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>> my[1];
cout << "The quotient is : ";
cout << my[0] / my[1] << endl;
exit();
}
void exit()
{
cout << " Press 0 to Exit" <<endl>> quit;
if (quit == 0)
{
exit(0);
}
}