elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / Podrian ayudarme a hacer funcional el menu con Do While, gracias. en: 15 Julio 2020, 23:10 pm
Código
  1. #include <iostream>
  2. #include <locale.h>
  3. #include <string>
  4.  
  5.  
  6. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  7. using namespace std;
  8.  
  9. int main(int argc, char** argv) {
  10. int entero;
  11. float real;
  12. char caracter;
  13. string cadena;
  14.  
  15.  
  16.    /*opcion*/int opc;
  17.  
  18.     do {
  19.     cout<<"OPCIONES\n";
  20. cout<<"1-ENTERO\n";
  21. cout<<"2-REAL\n";
  22.    cout<<"3-CARACTER\n";
  23.    cout<<"4-CADENA\n";
  24.  
  25.    cout<<"SELECCIONA UNA OPCION 1-4: ";
  26.    cin>> opc;
  27.  
  28.    switch(opc){
  29.     case 1:
  30.     cout<< "INTRODUCE UN NUMERO ENTERO: ";
  31.     cin>> entero;
  32.     break;
  33.     case 2:
  34.     cout<< "INTRODUCE UN NUMERO REAL: ";
  35.     cin>> real;
  36.     break;
  37.     case 3:
  38. cout<< "INTRODUCE UN CARACTER: ";
  39.     cin>> caracter;
  40.     break;
  41. case 4:
  42. cout<< "INTRODUCE UNA CADENA: ";
  43.     cin>> cadena;
  44.     break;
  45.    }
  46. } while (opc!=4);
  47. [code/]

[MOD] para publicar codigo usar las etiquetas GeSHi
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines