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