Advertisement
Brandford

Sentencias de Condicion

Mar 30th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void sentencias_condicion(void)
  5. {
  6.     int num1, num2, num3;
  7.    
  8.     system("clear");
  9.     printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  10.     printf("\nlearnc - Aprendizaje de C con IDE Anjuta\n");
  11.     printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  12.     printf("\n\nModulo: Sentencias de Condicion");
  13.     printf( "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n" );
  14.     printf("-\n");
  15.    
  16.     printf( "IF/ELSE\n\n" );
  17.    
  18.     printf( "Ingrese numero: " );
  19.     scanf( "%i", &num1 );
  20.    
  21.     if( num1==10 )
  22.     {
  23.         printf( "El numero ingresado ES 10\n\n" );
  24.     }
  25.     else
  26.     {
  27.         printf( "El numero NO ES 10\n\n" );
  28.     }
  29.        
  30.     getchar();
  31.    
  32.     printf( "IF/ELSE IF\n\n" );
  33.    
  34.     printf( "Ingrese un numero: ");
  35.     scanf( "%i", &num2 );
  36.    
  37.     if( num2>=1 && num2<=10 )
  38.     {
  39.         printf( "El rango de ingreso esta dentro de 1-10\n\n" );
  40.     }
  41.     else if( num2>=11 && num2 <=20 )
  42.     {
  43.          printf( "El rango de ingreso esta dentro de 11-20\n\n" );
  44.     }
  45.     else if( num2>= 21 && num2 <= 30 )
  46.     {
  47.          printf( "El rango de ingreso esta dentro de 21-30\n\n" );
  48.     }
  49.     else if( num2>=31 && num2 <= 40 )
  50.     {
  51.          printf( "El rango de ingreso esta dentro de 31-40\n\n" );
  52.     }
  53.     else if( num2>41 && num2 <= 50 )
  54.     {
  55.          printf( "El rango de ingreso esta dentro de 41-50\n\n" );
  56.     }
  57.     else if( num2 > 50 )
  58.     {
  59.          printf( "El numero ingresado esta fuera del rango establecido\n\n" );
  60.     }
  61.  
  62.     getchar();
  63.  
  64.     printf("SWITCH\n\n");
  65.    
  66.     printf( "Ingrese un numero: " );
  67.     scanf( "%i", &num3 );
  68.    
  69.     switch( num3 )
  70.     {
  71.             case  1:
  72.             {
  73.                   printf( "Ha ingresado el numero 1\n" );
  74.                   break;
  75.             }
  76.             case 2:
  77.             {
  78.                   printf( "Ha ingresado el numero 2\n" );
  79.                   break;
  80.             }
  81.             case 3:
  82.             {
  83.                  printf( "Ha ingresado el numero 3\n" );
  84.                  break;
  85.             }
  86.             default:
  87.             {
  88.                    printf( "Ha ingresado otro numero\n" );
  89.             }
  90.     }
  91.    
  92.     getchar();
  93.  
  94.     printf("-\n\n\n");
  95.     printf("Presione <ENTER> para continuar . . .");
  96.     //getchar();
  97.     fflush(stdin);
  98.     getchar();
  99.     system("clear");
  100.  
  101.     //return(0);  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement