Help with program

This is a discussion on Help with program within the C++ Programming forums, part of the General Programming Boards category; Trying to write a program where a user types a sentence in and the program returns a table indicating the ...

  1. #1
    Unregistered
    Guest

    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
    Posts
    104
    Yeah, this code makes so:
    http://www.cpp-home.com/code.php?33_1

    It just reads a file but not sentence, but you can get the algorithm...
    Ilia Yordanov,
    http://www.cpp-home.com ; C++ Resources

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

  4. #4
    Unregistered
    Guest
    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, 12: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, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21