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 |
Why c is called procedure oriented language?
write a program to copy a string without using a string?
What is c token?
What is integer constants?
What is the difference between char array and char pointer?
which will be first in c compiling ,linking or compiling ,debugging.
What is void pointers in c?
1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
please tell me the logic for this C program : INPUT (string):ABCD OUTPUT :BCDA CDAB DABC
Explain function pointer with exapmles.
Why doesnt that code work?
Why cd or dvd are round why not square.