Това е обикновен калкулатор, който ще може да извършва основни математически действия.
Кода е следния:
#include
<iostream>
#include <cmath> //тази библиотека не е
задължителна
using namespace std;
int main()
{
double a, b, g;
char c;
cout<<"This is a
simple
calculator!!n------------------------------------------------n------------------------------------------------n";
cout<<"Shoose an action | + | - | * | / |n";
cin>>c;
if (c == '+' || c == '-' || c == '*' || c == '/')
{
cout<<"......................nn";
cout<<"Enter first
number: ";
cin>>a;
cout<<"......................nn";
cout<<"Enter second
number: ";
cin>>b;
cout<<"......................nn";
if (c == '+')
{
g = a+b;
cout<<a<<c<<b<<"="<<g<<endl;
cout<<"------------------------------------------------nBy
Yasenn------------------------------------------------n";
}
if (c == '-')
{
g = a-b;
cout<<a<<c<<b<<"="<<g<<endl;
cout<<"------------------------------------------------nBy
Yasenn------------------------------------------------n";
}
if (c == '*')
{
g = a*b;
cout<<a<<c<<b<<"="<<g<<endl;
cout<<"------------------------------------------------nBy
Yasenn------------------------------------------------n";
}
if (c == '/')
{
g = a/b;
cout<<a<<c<<b<<"="<<g<<endl;
cout<<"------------------------------------------------nBy
Yasenn------------------------------------------------n";
}
}
else
{
cout<<"......................nnYou are so adopted
*_*n------------------------------------------------nBy
Yasenn------------------------------------------------n";
}
system("pause");
return
0;
}