I'm making a calculator and it´s supposed to be able to "erase or go back". Most of the other questions I have found online talk about how they reset the program, not how to go back/erase one step.
EDIT: I want to make a calculator that can: add, sub, div, multi, erase and reset. I know/will figure out how to do all of these but not the erase one. Like on a normal calculator you can use the AC/EC button to erase the last number that was written, but i dont know how to do this in code or what to search for to understand it.
This is the code so far:
#include<iostream>
using namespace std;
int main()
{
char op;
float num1,num2;
cout << "Enter operator either + or - or * or / :";
cin >>op;
cout<<">Enter two operands :";
cin >>num1>>num2;
switch(op)
{
case'+':
cout<<num1+num2;
break;
case '-':
cout<<num1-num2;
break;
case '*':
cout<<num1*num2;
break;
case '/':
cout<<"The answer is " <<num1/num2;
break;
default:
cout<<"The operator is not correct ";
}
return 0;
}