also I had an eror (Unreachable code) the reason of the program is to give the prular of an english world and I didn't finished it yet --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- this is my code please help me
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
char word[100];
int len;
printf("plz enter a word : ");
fflush(stdin);
gets(word);
len=strlen(word);
char nword[100]={(char)malloc(len+3)};
if(word[len-1]=='s'||'S')
{
strcpy(nword,word);
nword[len]='e';
nword[len+1]='s';
nword[len+2]='\0';
printf("the plural of your word is (%s)\n",nword);
free(nword);
}
if(word[len-1]=='s'||'S')
{
strcpy(nword,word);
nword[len]='e';
nword[len+1]='s';
nword[len+2]='\0';
printf("the plural of your word is (%s)\n",nword);
free(nword);
}
else if(word[len-1]=='x'||'X')
{
strcpy(nword,word);
nword[len]='e';
nword[len+1]='s';
nword[len+2]='\0';
printf("the plural of your word is (%s)\n",nword);
free(nword);
}
else if(word[len-1]=='z'||'Z')
{
strcpy(nword,word);
nword[len]='e';
nword[len+1]='s';
nword[len+2]='\0';
printf("the plural of your word is (%s)\n",nword);
free(nword);
}
else if(word[len-2]=='c'||'C'&&word[len-1]=='h'||'H')
{
strcpy(nword,word);
nword[len]='e';
nword[len+1]='s';
nword[len+2]='\0';
printf("the plural of your word is (%s)\n",nword);
free(nword);
}
else if(word[len-2]=='s'||'S'&&word[len-1]=='h'||'H')
{
strcpy(nword,word);
nword[len]='e';
nword[len+1]='s';
nword[len+2]='\0';
printf("the plural of your word is (%s)\n",nword);
free(nword);
}
else printf("ddd");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire