I am complete starter and i cant figure out how to use the while function in a very simple calucator code.
ive already tried putting the while function in the code in different ways but nothing of it seems to work it just stop without even giving me the final result of the first "problem"
#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
int number1;
int number2;
char op;
int result;
cout << "Give first number: ";
cin >> number1;
cout << "Give second number: ";
cin >> number2;
cout << "Chose operator(+ - / * ): ";
cin >> op;
if (op == '+')
{
result = number1 + number2;
}
else if (op == '-')
{
result = number1 - number2;
}
else if (op == '*')
{
result = number1 * number2;
}
else if (op == '/')
{
result = number1 / number2;
}
cout << "The result is: " << result << endl;
system("pause");
return 0;
}
everything its working fine this way i just want it to loop after the first problem and ask again for another one...