marzo 01, 2013

EJEMPLO: PROGRAMA DONDE INGRESA EL SEXO DE UNA PERSONA Y VE SI ES HOMBRE O MUJER


 Ingresar el sexo de una persona como " f o " m ", luego informar "es hombre" si ingreso una m, o "es mujer" si ingreso una f.


void main()
{
char sexo;

printf("Ingrese sexo: ");
scanf("%c",&sexo);
fflush(stdin);

if (sexo=='f')
printf("\nEs mujer");
if (sexo=='m')
printf("Es hombre");

getch();

}


o también:

void main()
{
char sexo;

printf("Ingrese sexo: ");
sexo = getch();
if (sexo=='f')
printf("\nEs mujer");
if (sexo=='m')
printf("Es hombre");

getch();

}

No hay comentarios:

Publicar un comentario