Thread: Succeeding Lettters

  1. #1
    Registered User
    Join Date
    Feb 2016
    Posts
    2

    Question Succeeding Lettters

    How to create a program that counts the number of pairs of succeeding letters in a given phrase. The program will stop when the enter key is hit. For example, the phrase “a bC_df g” has four such pairs: ab, bc, cd and fg. Note that characters aside from letters are disregarded and it also doesn’t matter whether the letter is in upper case or in lower case?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,321
    Come up with the algorithm first. It may be easier if you assume that the input is entirely lowercase and consists only of characters in the English alphabet. Later, extend your algorithm to handle non-alphabetic input. Handling uppercase is easy since tolower from <ctype.h> can be used to convert from uppercase to lowercase.

    Then, when you have an algorithm that you think will work, implement it. Do not worry about input at first: just hard code the strings, e.g.,
    Code:
    const char input[] = "a bC_df g";
    After you have everything working except the input part, implement the reading of input.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    4,508
    Strange how the wording of this post is identical (except for the preface of "How to...") to the wording of a post by a different user.

    Two people with the same exact assignment simply copy/pasted verbatim?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why only the succeeding value adds up???
    By omarbags in forum C Programming
    Replies: 18
    Last Post: 01-01-2009, 02:28 PM

Tags for this Thread