Buenas solo llevo 2 días con c ++ y necesito consejos ya que estoy un poco bloqueado, tengo lo siguiente:
#include <iostream>
using namespace std;
int main() {
double firstnum; double seconnum; double thirnum; double fournum;
string operation; string operation2;
double plus ;double minus; double mul; double div;
cout << "Please enter 2 operations: ";
cin >> firstnum >> operation >> seconnum; // numbers for first operation
cin >> thirnum >> operation2 >> fournum; // numbers for second numbers
if (operation=="+" || operation=="plus" ) {
plus = firstnum + seconnum;
cout << "The first sum is: " << plus << endl;}
if (operation=="-" || operation=="minus") {
minus = firstnum - seconnum;
cout << "The first minus is: " << minus << endl;}
if (operation=="*" || operation=="mul") {
mul = firstnum * seconnum;
cout << "The first multiplication is: " << mul << endl;}
if (operation=="/" || operation=="div"){
if (seconnum==0) {
cout << "cero is impossible to operate" << endl; }
div = firstnum / seconnum ;
cout << "The first div is: " << div << endl; }
if (operation2=="+" || operation2=="plus" ) {
plus = thirnum + fournum;
cout << "The second sum is: " << plus << endl;}
if (operation2=="-" || operation2=="minus") {
minus = thirnum - fournum;
cout << "The second minus is: " << minus << endl;}
if (operation2=="*" || operation2=="mul") {
mul = thirnum * fournum;
cout << "The second multiplication is: " << mul << endl;}
if (operation2=="/" || operation2=="div"){
if (fournum==0) {
cout << "cero is impossible to operate" << endl; }
div = thirnum / fournum;
cout << "The second div is: " << div << endl; ;
}
}
El problema que meto la primera operación al poner una division entre 0 quiero que siga con la segunda operación y no que me diga que es infinito, esta un poco guarrete pero para 2 días que llevo me doy por satisfecho al día de hoy, consejos ayudas? gracias de antemano