online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <cstdlib> // Pour la fonction atoi() using namespace std; int main() { string operation; cout << "Entrez une opération sur des entiers : "; cin >> operation; int resultat = 0; char operateur = '+'; // Recherche de l'opérateur et des opérandes int i = 0; while (i < operation.length()) { if (operation[i] == '+' || operation[i] == '-' || operation[i] == 'x' || operation[i] == '/') { operateur = operation[i]; break; } i++; } // Extraction des opérandes string operande1 = operation.substr(0, i); string operande2 = operation.substr(i + 1); // Conversion des opérandes en entiers int nombre1 = atoi(operande1.c_str()); int nombre2 = atoi(operande2.c_str()); // Calcul du résultat en fonction de l'opérateur switch (operateur) { case '+': resultat = nombre1 + nombre2; break; case '-': resultat = nombre1 - nombre2; break; case 'x': resultat = nombre1 * nombre2; break; case '/': resultat = nombre1 / nombre2; break; default: cout << "Opérateur invalide !" << endl; return 0; } // Affichage du résultat cout << operande1 << " " << operateur << " " << operande2 << " = " << resultat << endl; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue