-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathanagram.c
More file actions
40 lines (39 loc) · 760 Bytes
/
anagram.c
File metadata and controls
40 lines (39 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# include<stdio.h>
# include<string.h>
void anagram(char s[],char t[])
{
int i,j,c=0;
if(strlen(s)!=strlen(t))
{
printf("Not an anagram");
}
else
{
for(i=0;s[i]!='\0';i++)
{
for(j=0;s[j]!='\0';j++)
{
if(s[j]==t[i])
c++;
}
}
if(strcmp(s,t)!=0&&c==strlen(s))
{
printf("%s and %s are anagrams.",s,t);
}
else
{
printf("Not anagrams.");
}
}
}
int main()
{
char s[50],t[50];
printf("Enter the string:");
scanf("%s",s);
printf("Enter another string:");
scanf("%s",t);
anagram(s,t);
return 0;
}