forked from swaaz/basicprograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.c
More file actions
31 lines (31 loc) · 709 Bytes
/
Copy pathprogram.c
File metadata and controls
31 lines (31 loc) · 709 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
#include<stdio.h>
int main()
{
char a[100],b[100];
int f[26]={0};
int s[26]={0};
int k;
int len1,len2;
printf("Enter the two strings\n");
fgets(a,100,stdin);
fgets(b,100,stdin);
for(int i=0;a[i]!='\0';++i)
f[a[i]-'a']+=1;
for(int i=0;b[i]!='\0';++i)
s[b[i]-'a']+=1;
len1 = sizeof(a)/sizeof(a[0]);
len2 = sizeof(b)/sizeof(b[0]);
if(len1 == len2)
{
for(k=0;k<26;++k)
if(f[k]!=s[k])
break;
if(k==26)
printf("The strings are anagrams.\n");
else
printf("The strings aren't anagrams.");
}
else
printf("The strings aren't anagrams.");
return 0;
}