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
Explain the working of Array with Strings? A string is defined in C language as an array of characters. A null character (‘\0') is automatically added to the end of the charact

#include stdio.h #include math.h float discharge(float,float); void main()   {   char prompt;      float time,out,cr;   cr = 100e-6;   for (time = 0;time   {   /* call th

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''''a''''-''''z'''') and

Develop Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: C

Write two different arrays. Store the names in it and then compare if both the names entered by the user are the same.

C program for function  of average int average(int); void main() {           int max=0,c=0;           clrscr();           printf("ENTER THE LIMIT OF INPUT FOR AV

Suppose that three integer variables intA, intB, and intC have already been defined at the beginning of the main function, write a single C++ statement to read three integers from

What data structure would you mostly likely see in a nonrecursive implementation of a recursive algorithm?Minimum 100 words accepted#

Make QtAV Videoplayer simple integrateable for Qt Applications Project Description: I'm preparing an application for Windows and Mac using QtCreator. I want a videoplayer

in mobiles mumbers to alphabets