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 can I read in an object file and jump to locations in it?
plz answer....A program that takes 3 variables e.g a,b,c in as seperate parameters and rotates the values stored so that value goes a to b, b to c and c to a .
What is key word in c language?
What is the use of sizeof () in c?
in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?
What is c language and why we use it?
Tell me a C program to display the following Output? 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
Explain how can I write functions that take a variable number of arguments?
i have a written test in tomorrow
what is pointer?
13 Answers HCL, TCS,
Which is best linux os?
Write a c program using for loop in switch case?