how to find anagram without using string functions using
only loops in c programming
Answer Posted / 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 |
Post New Answer View All Answers
simple program of graphics and their output display
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
What does the error message "DGROUP exceeds 64K" mean?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
develop algorithms to add polynomials (i) in one variable
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
Explain that why C is procedural?
What is the difference between the local variable and global variable in c?
Explain the difference between the local variable and global variable in c?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Is c language still used?
Why main is not a keyword in c?
What is the difference between exit() and _exit() function?
What do the functions atoi(), itoa() and gcvt() do?