gonzalob

Untitled

Jun 9th, 2020
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int numero = 3;
  7.     char mander = 's';
  8.  
  9.     /*
  10.     if ( (numero > 0) && (numero < 10) || (mander == 'p') )
  11.     {
  12.         printf("entro");
  13.     }
  14.     else
  15.     {
  16.         printf("no entro\n");
  17.     }
  18.     */
  19.  
  20.     /*
  21.     if (numero == 4)
  22.     {
  23.          printf("entro 4");
  24.     }
  25.     else if (numero == 3)
  26.     {
  27.         printf("entro 3");
  28.     }
  29.      else if (numero == 2)
  30.     {
  31.         printf("entro 2");
  32.     }
  33.     else
  34.     {
  35.         printf("entro otro");
  36.     }
  37.     */
  38.  
  39.     /*
  40.     int nota = 4;
  41.  
  42.     if (nota <=0)
  43.     {
  44.         printf("incorrecta");
  45.     }
  46.     else if ((nota >=8) && (nota <=10))
  47.     {
  48.          printf("promociono");
  49.     }
  50.     else if((nota >=5) && (nota <=7))
  51.     {
  52.         printf("aprobo");
  53.     }
  54.     else if (nota == 4)
  55.     {
  56.         printf("desaprobo");
  57.     }
  58.     else if (nota > 10)
  59.     {
  60.          printf("super genio");
  61.     }
  62.     else
  63.     {
  64.         printf("aplazo");
  65.     }
  66.     */
  67.  
  68.     int indice = 0;
  69.  
  70.     for (indice = 0; indice < 5;indice++)
  71.     {
  72.         printf("ingrese un numero %d \n",indice);
  73.         //scanf("%d",&numero);
  74.     }
  75.  
  76.     int indice2 = 10;
  77.     for (indice2 = 10; indice2 >= 0;indice2--)
  78.     {
  79.         printf("numero %d \n",indice2);
  80.     }
  81.  
  82.     //Desarrolle un algoritmo que permita
  83.     //visualizar el cuadrado de los números entre 80 y 100.
  84.  
  85.     int inicio = 80;
  86.     int fin = 100;
  87.     int cuadrado = 0;
  88.  
  89.     for (inicio = 80;inicio<=fin;inicio++)
  90.     {
  91.             cuadrado = inicio * inicio;
  92.             printf("el cuadrado de %d es de %d\n",inicio,cuadrado);
  93.     }
  94.  
  95.  
  96.     //Realizar un algoritmo que permita cargar de 10 valores
  97.     //por teclado y nos muestre posteriormente
  98.     //la suma de los valores ingresados y su promedio.
  99.  
  100.     /*
  101.  
  102.     indice = 0;
  103.     int suma = 0;
  104.     float promedio = 0;
  105.  
  106.     for (indice = 0;indice < 5; indice++)
  107.     {
  108.         printf("ingrese un numero %d \n",indice+1);
  109.         scanf("%d",&numero);
  110.         suma = suma + numero;
  111.     }
  112.  
  113.     promedio = (float)suma / (float)indice;
  114.     printf("el promedio es %f \n",promedio);
  115.  
  116.  
  117.  
  118.     mander = 's'; //este verdaderas con respecto a la condicion
  119.     numero = 0;
  120.     while ((mander == 's') && (numero < 10))
  121.     {
  122.         printf("hola %d\n",numero);
  123.         printf("ingrese s si desea seguir? \n");
  124.         fflush(stdin);
  125.         //tener en cuenta que los valores tienen y DEBEN cambiar
  126.         scanf("%c",&mander);
  127.         numero = numero + 1;
  128.     }
  129.  
  130.     */
  131.  
  132.     /*
  133.     Una planta que fabrica piezas posee un lote de n piezas.
  134.     y luego ingrese la longitud de cada pieza; sabiendo que
  135.     la pieza cuya longitud esté comprendida en el rango de 1,20 y 1,30 son aptas.
  136.     Imprimir por pantalla la cantidad de piezas aptas que hay en el lote.
  137.  
  138.     */
  139.  
  140.     char hayPiezas = 's';
  141.     int contarPiezasAptas = 0;
  142.     float tam = 0;
  143.  
  144.  
  145.     while ( hayPiezas == 's' )
  146.     {
  147.         printf("cual es la longitud de esta pieza?\n");
  148.         fflush(stdin);
  149.         scanf("%f",&tam);
  150.         if ( (tam >=1.20) && (tam <=1.30) )
  151.         {
  152.             contarPiezasAptas = contarPiezasAptas + 1;
  153.  
  154.         }
  155.  
  156.         printf("ingrese s si desea seguir y + pieza? \n");
  157.         fflush(stdin);
  158.         //tener en cuenta que los valores tienen y DEBEN cambiar
  159.         scanf("%c",&hayPiezas);
  160.     }
  161.  
  162.     printf("la cantidad de piezas aptas son ... %d",contarPiezasAptas);
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.     return 0;
  170. }
Advertisement
Add Comment
Please, Sign In to add comment