This program predicts the gender of a person with his/her Name
logic: This program compares the last characters of the string with names
Program :
#include<stdio.h>
#include<string.h>
int main()
{
char s[100],c;
m:
system(“cls”);
b:
printf(“enter the name (in lower case) :”);
scanf(“%s”,s);
if(strlen(s)>=3)
{
if(s[strlen(s)-1]==s[strlen(s)-2])
{
printf(“nnenter a valid namenn”);
goto b;
}
if(s[(strlen(s))-1]==’i’||s[(strlen(s))-1]==’u’||s[strlen(s)-1]==’a’||s[strlen(s)-4]==’d’||s[strlen(s)-1]==’i’)
{
printf(“nn%s is female”,s);
}
else
{
printf(“nn%s is male”,s);
}
}
else
{
printf(“nnenter a valid namenn”);
goto b;
}
printf(“nndo u want to continue(y/n):”);
fflush(stdin);
scanf(“%c”,&c);
if(c==’y’)
{
goto m;
}
}