answersLogoWhite

0

C programming code for anagram

Updated: 10/24/2022
User Avatar

Wiki User

12y ago

Best Answer

#include <stdio.h>

#include <ctype.h>

#define N 26 /* lenght of array */

int main()

{

char ch;

int count[N] = {0};

int x;

printf("Enter first word: ");

while ((ch = getchar()) != '\n')

{

if (isalpha(ch))

{

count[toupper(ch) - 'A']++;

}

}

printf("Enter second word: ");

while ((ch = getchar()) != '\n')

{

if (isalpha(ch))

{

count[toupper(ch) - 'A']--;

}

}

for (ch = 0; ch < N; ch++)

{

if (count[ch] != 0)

x = 1;

}

if (x == 1)

{

printf("The two words are not anagrams.\n");

}

else

{

printf("The two words are anagrams.\n");

}

return 0;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C programming code for anagram
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Code for creating pascal's triangle in C programming language?

code for creating pascal's triangle in C programming language?


Getting source code of c?

C is a programming language, so it doesn't have source code.(On the other hand, C compilers do have source code, but you, as a beginner in programming, could not understand them.)


Where can one find C programming tutorials?

You can find C programming tutorials online at the C programming website. They provide both free and paid tutorials for many aspects of the C and C++ code.


What does generic programming in c plus plus means?

Generic programming means that the code is generic enough that it compile on any C++ implementation. That is, it has no platform-specific code.


What is c and why you use?

C is a programming language, and it's mostly used for Systems Programming. Most kernels these days have at least some C code in them.


Microsoft office's source code written by which programming language?

C++


How Create mouse in C programming source code?

Here is the article for Mouse programming in C. In this link full details are given nicely.http://electrofriends.com/articles/computer-science/c-tutorials/mouse-programming-in-cc/


What is programming languages in c plus plus?

Programming in C++ means designing and writing a computer program using the C++ programming language. C++ is a high-level, machine-independent language which must be converted into machine-dependent code by a compiler.


What is Turbo C download used for?

Turbo C is a compiler for a general purpose computer programming language called C. It transforms code written in C into the computer language needed for executable programming.


C programming source code for push down automata?

i cant sorry


What do you mean by c taken programming in c?

A C program is a computer program written using the C programming language.


What translator is needed for C programming language?

To translate the C source code program, you need a program called a "C compiler".