How many non-letters are included in the string, C/C++ Programming

Write a fully modular C program that reads in a string of a defined size from the keyboard and reports how many times each letter of the alphabet occurs within that string (ignoring case). It should also report how many non-letters are included in the string.


 Although this is a relatively simple problem, doing it well is slightly more complicated than it may look at first.  Here are some hints:

·  The obvious solution is simply to iterate through the string using a gigantic switch-case statement to increment one of 27 integer variables (one for each of the letters of the alphabet and an additional variable to store the non-alphabetic characters).  This is the WRONG solution: it will work but it's a poor design and is inefficient and will NOT give you good marks.

·  To solve the problem much more elegantly and with code that is a tiny fraction of the length, you first need to think about the data required to be stored.  In particular, try to identify a certain complex data type that is well-suited to store large amounts of data all of the same type.

·  Once you've done this, you then need to find a way of mapping each character in the string to the appropriate element in your data: this is actually much easier than it initially looks if you remember how character data is really stored internally and bear in mind the ordinal properties of the alphabetic characters of either case in the ASCII table (remember you can ignore case by simply converting the entire string to all one case).

 

Posted Date: 3/13/2013 8:28:18 AM | Location : United States







Related Discussions:- How many non-letters are included in the string, Assignment Help, Ask Question on How many non-letters are included in the string, Get Answer, Expert's Help, How many non-letters are included in the string Discussions

Write discussion on How many non-letters are included in the string
Your posts are moderated
Related Questions
please provide me the assignment help. What is the difference between a copy constructor and an overloaded assignment operator?

Many human diseases could be controlled by the knowledge of the gene’s structure and pattern. The human gene could be represented by four nucleotides. Each nucleotide is represente

Why should I employ new instead of truthful old malloc()? A: Constructors/destructors, type safety, overridability. Constructors/destructors: unlike malloc(sizeof(Fred)), new

Develop Diablo 2 LOD 1.13d Dupe Method for Closed Battle.net This hack is for diablo 2 lord of destruction The program must work on all realms, all cores, all ladders (4x rea

#questThere is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doin

Write a program that takes 3 small letters as input and sort them according to their ASCII value.

Write a program to add co-ordinates of the plane The class having x and y co-ordinates. Create three objects. Use a constructor to pass one pair of co-ordinates and a funct

find the c program to find area under the curvey=f(x)   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area;

C program to string compression: Write a program to define a sting and all operations on string. void main()                                 {

In rPeANUt implement the "char getchar()" and "void printstring(char *str)" functions. Using these functions implement the following: void main() {    while (1) {       ch