From 3927675ae33ee13798c8040e4d3ec1068e05db1a Mon Sep 17 00:00:00 2001 From: Tanushree Aggarwal <47485195+shreetanu@users.noreply.github.com> Date: Thu, 1 Oct 2020 02:12:44 +0530 Subject: [PATCH 1/2] Create program.c A program that checks whether two strings are Anagrams or not --- C/program-54/program.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 C/program-54/program.c diff --git a/C/program-54/program.c b/C/program-54/program.c new file mode 100644 index 00000000..aebae69a --- /dev/null +++ b/C/program-54/program.c @@ -0,0 +1,31 @@ +#include +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; +} From ea5fdebe567aec98a3d0ce0e782cb3da73cae9f3 Mon Sep 17 00:00:00 2001 From: Tanushree Aggarwal <47485195+shreetanu@users.noreply.github.com> Date: Thu, 1 Oct 2020 02:15:42 +0530 Subject: [PATCH 2/2] Create Readme.md --- C/program-54/Readme.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 C/program-54/Readme.md diff --git a/C/program-54/Readme.md b/C/program-54/Readme.md new file mode 100644 index 00000000..cdd202e2 --- /dev/null +++ b/C/program-54/Readme.md @@ -0,0 +1,3 @@ +A program in C which checks whether two strings are anagrams or not + +An anagram of a string is another string that contains same characters, only the order of characters can be different.