0

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 :confused:

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by Chainsaw
0

From the sounds of it, you'd have a bunch of functions like this:

void Print_a()
{
    printf("a");
}

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

void Print_apple()
{
    Print_a();
    Print_p();
    Print_p();
    Print_l();
    Print_e();
}

and so on.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.