struct alumno

Anuncio
// Prueba de registro ó estructura en C
// ---------------------------------------------#include <stdio.h>
main()
{
enum beca {Falso, Verdadero};
struct alumno {
int lu;
char apellido[30];
enum beca tiene_beca;
float promedio;
};
struct alumno a;
int opcion;
system ("cls"); //borra pantalla
printf("Ingrese los datos del alumno:\n");
printf ("\nLU:");
scanf("%i",&a.lu);
fflush(stdin); // fflush(stdin) sirve para limpiar el buffer de entrada de teclado.
// Se usa después de un scanf o un gets para evitar que guarde un enter en el buffer
// STDIN, significa 'Standard Input', es decir, el ingreso por teclado.
printf ("\nApellido y nombre:");
gets(a.apellido);
printf ("\nSi tiene beca presione 1, sino 0:");
scanf("%i", &opcion);
switch (opcion)
{
case 0: a.tiene_beca = Falso;
break;
case 1: a.tiene_beca = Verdadero;
break;
};
printf ("\nIngrese promedio:");
scanf("%f", &a.promedio);
printf("Los datos del alumno son:\n");
printf("LU:%i",a.lu);
printf ("\nApellido y nombre: %s", a.apellido);
switch (a.tiene_beca)
{
case 0: printf("\nNo tiene beca");
break;
case 1: printf("\nTiene beca");
break;
};
printf ("\nPromedio:%f", a.promedio);
printf ("\n");
system ("pause");
}
Descargar