naquo

Ejercicio simple de C

Mar 5th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int Promedio;
  5. char Nombre[2][256]; // Nombre[0] es el nombre y Nombre[1] es el apellido
  6.  
  7. void CargarAlumno();
  8. void VerAlumno();
  9.  
  10. int main(int argc, char *argv) {
  11.     int Opcion = 1;
  12.     do {
  13.         printf("1. Cargar alumno\n");
  14.         printf("2. Ver alumno\n");
  15.         printf("0. Salir\n");
  16.         printf("\nIngrese una opcion: ");
  17.         scanf("%i", &Opcion);
  18.         system("cls");
  19.         switch(Opcion) {
  20.             case 1:
  21.                 CargarAlumno();
  22.                 break;
  23.             case 2:
  24.                 VerAlumno();
  25.                 break;
  26.         }
  27.     } while(Opcion != 0);
  28.     return 1;
  29. }
  30.  
  31. void CargarAlumno() {
  32.     int CantidadDeNotas = 0;
  33.     int SumaTotal = 0;
  34.     printf("Ingrese el nombre del alumno: ");
  35.     scanf("%s", Nombre[0]);
  36.     printf("Ingrese el apellido del alumno: ");
  37.     scanf("%s", Nombre[1]);
  38.     printf("Ingrese 3 notas (del 1 al 10)");
  39.     for(CantidadDeNotas = 0; CantidadDeNotas < 3; CantidadDeNotas++) {
  40.         int Nota;
  41.         scanf("%i", &Nota);
  42.         SumaTotal += Nota;
  43.     }
  44.     Promedio = SumaTotal / 3;
  45. }
  46.  
  47. void VerAlumno() {
  48.     printf("Nombre: %s\tApellido: %s\tPromedio: %i", Nombre[0], Nombre[1], Promedio);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment