Thread: Help with program

  1. #1

    Help with program

    Trying to write a program where a user types a sentence in and the program returns a table indicating the number of occurences of each letter of the alpabet in that sentence. Any suggestions??

  2. #2
    Registered User
    Join Date
    Oct 2001
    Yeah, this code makes so:

    It just reads a file but not sentence, but you can get the algorithm...
    Ilia Yordanov, ; C++ Resources

  3. #3
    Is there any other way to do this?

  4. #4
    declare an array of 256 int called symbols
    intialize each element of symbols to zero
    declare an int called index
    obtain input
    determine length of input
    use loop to cast each char in input to an int and assign that value to index
    increment symbols[index] by 1;

    determine which values of ACSII (or whatever char set your compiler uses) correspond to the letters you wish to report on. Use a loop to display the letter corresponding the the element number as a charactrer and the value stored at the element is the number of times the character was found in whatever the input was.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM