Source Code :
/*
Name : Phirum Tan
NIM : 49012082
Major: TMD
*/
#include <iostream>
using namespace std;
float multi(float x , float y)
{
float result;
result = x * y ;
return result;
};
float addi(float x ,float y)
{
float result;
result = x + y ;
return result;
};
float sub(float x , float y)
{
float result;
result = x - y;
return result;
};
float divide(float x ,float y)
{
float result;
result = x / y;
return result;
};
int main()
{
int i;
float a , b , show;
cout << "This is Simple program calculator."
<< endl;
cout << "Press number 1 for Multi."
<< endl;
cout << "Press number 2 for Addition."
<< endl;
cout << "Press number 3 for Minus"
<< endl;
cout << "Press number 4 for Divide."
<< endl;
cin >> i;
switch(i)
{
case 1 :
{
cout << "Value 1 = "
<< endl;
cin >> a;
cout << "Value 2 = "
<< endl;
cin >> b;
show = multi(a,b);
cout << "Result = "
<< show
<< endl;
break;
}
case 2:
{
cout << "Value 1 = "
<< endl;
cin >> a;
cout << "Value 2 = "
<< endl;
cin >> b;
show = addi(a,b);
cout << "Result = "
<< show
<< endl;
break;
}
case 3:
{
cout << "Value 1 = "
<< endl;
cin >> a;
cout << "Value 2 = "
<< endl;
cin >> b;
show = sub(a,b);
cout << "Result = "
<< show
<< endl;
break;
}
case 4:
{
cout << "Value 1 = "
<< endl;
cin >> a;
cout << "Value 2 = "
<< endl;
cin >> b;
show = divide(a,b);
cout << "Result = "
<< show
<< endl;
break;
}
default :
cout << "Sorry you press wrong."
<< endl;
}
system ("pause");
return 0;
}
Video :
Link : http://youtu.be/KUnTKmyWEvo
Thanks for watching
Name : Phirum Tan
MIN : 49012082
Major : TMD
No comments:
Post a Comment