Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- double valor1=0;
- double valor2=0;
- char operacion=' ';
- double resultado=0;
- while(valor1==0){
- cout << "Ingrese el primer numero real distinto de cero :"<<"\n";
- cin>>valor1;
- }
- while(valor2==0){
- cout << "Ingrese el segundo numero real distinto de cero :"<<"\n";
- cin>>valor2;
- }
- while((operacion!='+' && operacion!='-' && operacion!='/' && operacion!='*')){
- cout << "Ingrese la operacion: + - * /"<<"\n";
- cin>>operacion;
- }
- if(operacion=='+'){
- resultado =valor1+valor2;
- }else{
- if(operacion=='-'){
- resultado =valor1-valor2;
- }else{
- if(operacion=='*'){
- resultado =valor1*valor2;
- }else{
- if(operacion=='*'){
- resultado =valor1/valor2;
- }
- }
- }
- }
- cout<<"El resultado es "<<resultado;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement