string summary analysis

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 1
Reputation: r1ian2 is an unknown quantity at this point 
Solved Threads: 0
r1ian2 r1ian2 is offline Offline
Newbie Poster

string summary analysis

 
0
  #1
Apr 15th, 2009
i need help on how to create a C++ program that will input string of characters and will count the number of different vowels, consonants and symbols included in the string.
Input a string => "program!"
total letter 'a' => 1
total letter 'e' => 0
total letter 'i' => 0
total letter 'o' => 1
total letter 'u' => 0

total vowels => 2
total consonants => 5
total symbols => 1
total characters => 8
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,407
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1467
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: string summary analysis

 
0
  #2
Apr 15th, 2009
Create 5 integers that will accumulate the counts for each vowel.
  1. print prompt to enter string
  2. accept keyboard input into std::string or character array variable
  3.  
  4. loop through each character in the string
  5. beginning of loop
  6. test for vowel
  7. if 'a' then increment a-counter
  8. else if 'e' then increment e-counter
  9. etc. for each vowel
  10. end of loop
  11.  
  12. print the value of each vowel counter
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 793
Reputation: siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of 
Solved Threads: 135
siddhant3s's Avatar
siddhant3s siddhant3s is online now Online
Master Poster

Re: string summary analysis

 
0
  #3
Apr 16th, 2009
Someone said that a program is algorithm+data structures.
Ancient has given you the algorithm. I would like to recommend a data structure:map to store the number of occurrence of each vowel.
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: string summary analysis

 
0
  #4
Apr 16th, 2009
1. Niklaus Wirth. Algorithms + Data Structures = Programs. Prentice Hall etc...
2. The char type values range provides much (much) more suitable data structure: a simplest 1D array. Be careful: char may be signed or unsigned (it's an implementation-defined issue)...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC