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 |
When is a void pointer used?
What are the main characteristics of c language describe the structure of ac program?
What is the correct declaration of main?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
How does C++ help with the tradeoff of safety vs. usability?
Explain the process of converting a Tree into a Binary Tree.
what is the use of ~ in c lang?????
Is c still used?
coding for Fibonacci.?
Explain about block scope in c?
main() { int age; float ht; printf("Enter height and age"); scanf("%d%d",&height,&age); if((age<=20)&&(ht>=5)) {printf("She loves you");} else {printf("She loves you");} }
is compiler do read the data line by line or not. ??
6 Answers LG Soft, Satyam, Tech Mahindra,