I'm a total beginner, so I thought : Hey, I should try and program a calculator, just for fun. After 1 hour of programming ( Yes, I'm THAT much of a beginner ) I finished my calculator, but after 1 use, I have to close, and open it again to be able to use it, and I looked in the internet for ways to loop it to no avail.
This is the complete code ( It's in spanish btw, but it shouldn't be a problem right? )
#include <iostream>
usingnamespace std;
int main ()
{
double num1, num2, resultado;
char letra;
cout << "Bienvenido a mi calculadora " << endl;
do{
cout << "\nColoca el primer numero" << endl;
cin >> num1;
cout << "coloca la operacion deseada ( + - * / ) " << endl;
cin >> letra;
cout << "Coloca tu segundo numero" << endl;
cin >> num2;
if(num1 + num2 > 0.0) // If num1 and num2 are greater than 0, then do math
// Just checking by adding the numbers. Negative numbers will still work
{
if(letra == '+')
{
resultado= num1 + num2;
cout << "el resultado de " << num1 << " mas " << num2 << " es igual a " << resultado << endl;
}
if(letra == '-')
{
resultado= num1 - num2;
cout << "el resultado de " << num1 << " menos " << num2 << " es igual a " << resultado << endl;
}
if(letra == '*')
{
resultado= num1 * num2;
cout << "el resultado de " << num1 << " por " << num2 << " es igual a " << resultado << endl;
}
if(letra == '/')
{
resultado= num1 / num2;
cout << "el resultado de " << num1 << " entre " << num2 << " es igual a " << resultado << endl;
}
}
}while(num1 + num2 > 0.0); // Keep asking calc problems until two zeros are inputted
return 0;
}