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
Introduction to C++ C++ was developed by Bjarne Stroustrup at Bell Laboratories in 1983. Originally, it was known as " C with class". C+ as an enhancement to the C language was

How to insert values in array - c++ program: Write a program to insert values in array void main() { int a[2][3][2]={                                 {

how to write the code for operation research

write a c++ program for minimum shelf downloads

I need to program a microprocessor that would have a temperature, gas, humidity and PIR sensor connected to it. It would send the data to a PC via a Zigbee and receive commands fro

We are seeking a talented developer/team with great experience in programming apps for both Android and iOS. Our project needs great skills and experience in making good functional


A Constructive Example Consider an example , to model a user-defined data type for  strings. The object simulates a character array ( string ) using a character pointer and an

write a c program chat illustrates the creation of child process using fork system call. One process finds sum of even series and other process finds sum of odd series.

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. #include float start_point,