Advertisement
Guest User

Ej4cpp

a guest
Oct 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.   double valor1=0;
  6.   double valor2=0;
  7.   char operacion=' ';
  8.  
  9.   double resultado=0;
  10.  
  11.   while(valor1==0){
  12.     cout << "Ingrese el primer numero real distinto de cero :"<<"\n";
  13.     cin>>valor1;
  14.   }
  15.  
  16.   while(valor2==0){
  17.     cout << "Ingrese el segundo numero real distinto de cero :"<<"\n";
  18.     cin>>valor2;
  19.   }
  20.  
  21.   while((operacion!='+' && operacion!='-' && operacion!='/' && operacion!='*')){
  22.     cout << "Ingrese la operacion: + - * /"<<"\n";
  23.     cin>>operacion;
  24.   }
  25.  
  26.  
  27.   if(operacion=='+'){
  28.     resultado =valor1+valor2;  
  29.   }else{
  30.     if(operacion=='-'){
  31.       resultado =valor1-valor2;  
  32.     }else{
  33.       if(operacion=='*'){
  34.         resultado =valor1*valor2;  
  35.       }else{
  36.         if(operacion=='*'){
  37.           resultado =valor1/valor2;  
  38.         }
  39.       }
  40.     }
  41.   }
  42.  
  43. cout<<"El resultado es "<<resultado;
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement