how to find anagram without using string functions using
only loops in c programming
Answer / csnr
#include<stdio.h>
int check(char [], char []);
main()
{
char a[100], b[100];
int flag;
printf("Enter first string\n");
gets(a);
printf("Enter second string\n");
gets(b);
flag = check(a, b);
if ( flag == 1 )
printf("\"%s\" and \"%s\" are anagrams.\n", a, b);
else
printf("\"%s\" and \"%s\" are not anagrams.\n", a, b);
return 0;
}
int check(char a[], char b[])
{
int first[26] = {0}, second[26] = {0}, c = 0;
while ( a[c] != '\0' )
{
first[a[c]-'a']++;
c++;
}
c = 0;
while ( b[c] != '\0' )
{
second[b[c]-'a']++;
c++;
}
for ( c = 0 ; c < 26 ; c++ )
{
if( first[c] != second[c] )
return 0;
}
return 1;
}
Is This Answer Correct ? | 11 Yes | 8 No |
how to print the character with maximum occurence and print that number of occurence too in a string given ?
Differentiate fundamental data types and derived data types in C.
how to create c progarm without void main()?
What is pointer to pointer in c with example?
what are the advantage and disadvantage of recursion
What is const volatile variable in c?
write a reverse string to print a stars.(with out using logic) ***** **** *** ** *
what is the answer for it main() { int i; clrscr(); printf("%d",&i)+1; scanf("%d",i)-1; }
What is the difference between memcpy and memmove?
1)which of following operator can't be overloaded. a)== b)++ c)?! d)<=
What are the characteristics of arrays in c?
What is getch?