Create Function that prints letters, words and sentences

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

Join Date: Sep 2004
Posts: 2
Reputation: lakessler1 is an unknown quantity at this point 
Solved Threads: 0
lakessler1 lakessler1 is offline Offline
Newbie Poster

Create Function that prints letters, words and sentences

 
0
  #1
Sep 21st, 2004
I am in a C++ class and find myself struggling with creating functions that use letters. I have to write out two sentences to the screen. But the assignment is create one function for each letter, space, carriage, return, and punctuation mark. Each word output is controlled by a function (calls each letter, etc function). Each sentence output is controlled by a function (calls each word function). I have read my text book over and over. I have even bought the book C++ for dummies. We have not studied strings or arrays. I know that if I wanted to type out the whole sentence I would have to have code like the following
#include <iostream>

using std::cout;
using std::endl;

//prototype
void Sentence (void);

void main (){
//call
Sentence ();
}

//definition

void Sentence (void){
cout << I need help << endl;
}

So my question is how do I do this a letter at a time and bring it all together using functions to create letters then words and then sentence Any help will be appreciated
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 11
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: Create Function that prints letters, words and sentences

 
0
  #2
Sep 21st, 2004
From the sounds of it, you'd have a bunch of functions like this:

  1. void Print_a()
  2. {
  3. printf("a");
  4. }

and then to make the word 'apple' you might have:

  1. void Print_apple()
  2. {
  3. Print_a();
  4. Print_p();
  5. Print_p();
  6. Print_l();
  7. Print_e();
  8. }

and so on.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC