Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

simple program of graphics and their output display

2004


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

1037


What does the error message "DGROUP exceeds 64K" mean?

1229


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

3265


develop algorithms to add polynomials (i) in one variable

2170


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

1517


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

1126


Explain that why C is procedural?

1147


What is the difference between the local variable and global variable in c?

967


Explain the difference between the local variable and global variable in c?

1077


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

1208


Is c language still used?

985


Why main is not a keyword in c?

1260


What is the difference between exit() and _exit() function?

1047


What do the functions atoi(), itoa() and gcvt() do?

1196