0

plss help me ......make a c program that will input two words and determine if they are anagram or not anagram if the same words they are identical.............this is my code but its not complete plss help me.........

# include <stdio.h>
# include <conio.h>
# include <string.h>

int main(){
int menu,i,j,ctr=0;
char fw[20],sw[20],let;
do
{clrscr();
printf ("[1] Enter String\n");
printf ("[2] Exit\n");
printf ("Please choose from the menu:");
scanf ("%d",&menu);
if (menu==1){
printf ("Enter the first word:");
scanf ("%s",&fw);
printf ("Enter the second word:");
scanf ("%s",&sw);
}
for (i=0;i<strlen(fw);i++)
{
let=fw[i];
for (j=0;j<strlen(sw);i++)
{
if (let==sw[j]);{
ctr++;
break;}
}
}
getch();
ctr=0;
}
while (menu!=2);
printf ("Press any key to terminate");
getch();
return 0;

}

Edited by Nick Evan: Added code-tags

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
0

What I would do is sort each of the words and then just compare them. Example: orchestra and carthorse would both become acehorst. Don't use string leterals do so this because they can not be changed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.