
Originally Posted by
fritzhahaha
i am using visual basic 2010 c++
this is..., zero divide ^_^
'cin' can be versatile bro, all you need is the variable unsa klase. the problem of C/C++ is its very explicit in terms of its input but..., you can mitigate this with other tricks if you know.
anyways, here is a bogo/crude way of doing what you wanted ^_^
it is advised unahon nimo ang 'operator' kay mulabad imo ulo if ma-ulahi na siya ^_^
note: wala ni siya security/bounds/etc checking...
Code:
char opt = '0';
cout << "Enter opt: ";
cin >> opt;
switch(opt)
{
case '+':
{
int n1 = 0, n2 = 0;
cout << "Enter n1: ";
cin >> n1;
cout << "Enter n2: ";
cin >> n2;
cout << "-----------------" << endl;
cout << "The sum is: " << n1 + n2 << endl;
}; break;
case '-':
{
int n1 = 0, n2 = 0;
cout << "Enter n1: ";
cin >> n1;
cout << "Enter n2: ";
cin >> n2;
cout << "-----------------" << endl;
cout << "The diference is: " << n1 - n2 << endl;
}; break;
case '*':
{
int n1 = 0, n2 = 0;
cout << "Enter n1: ";
cin >> n1;
cout << "Enter n2: ";
cin >> n2;
cout << "-----------------" << endl;
cout << "The product is: " << n1 * n2 << endl;
}; break;
case '/':
{
float n1 = 0, n2 = 0;
cout << "Enter n1: ";
cin >> n1;
cout << "Enter n2: ";
cin >> n2;
cout << "-----------------" << endl;
cout << "The quotient is: " << n1 / n2 << endl;
}; break;
case '%':
{
int n1 = 0, n2 = 0;
cout << "Enter n1: ";
cin >> n1;
cout << "Enter n2: ";
cin >> n2;
cout << "-----------------" << endl;
cout << "The modulo is: " << n1 % n2 << endl;
}; break;
default:
{
cout << "unknown" << endl;
}
}