| | |
Create Function that prints letters, words and sentences
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2004
Posts: 2
Reputation:
Solved Threads: 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
#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
From the sounds of it, you'd have a bunch of functions like this:
and then to make the word 'apple' you might have:
and so on.
C++ Syntax (Toggle Plain Text)
void Print_a() { printf("a"); }
and then to make the word 'apple' you might have:
C++ Syntax (Toggle Plain Text)
void Print_apple() { Print_a(); Print_p(); Print_p(); Print_l(); Print_e(); }
and so on.
![]() |
Similar Threads
- Anagram Function - Reapeated letters Problem (C++)
- tolower function does not work on certain letters (C++)
- newbie python question? (Python)
- How to output certain letters from words?? (C++)
- How can I create a user defined function (MS SQL)
- C++ Syntax (C++)
Other Threads in the C++ Forum
- Previous Thread: Using printf with a file
- Next Thread: virus found message when compiling my source code
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





