Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.6 KB

C-add-empty-functions.md

File metadata and controls

38 lines (28 loc) · 1.6 KB

C-add-empty-functions

We will add some more pieces to our program. All of these additions should still be in your same .cpp file. You should expect to keep building in this file through the end of the project.

Additional Functions

In Chapter 6, we will learn how to write our own functions. You may not know how to do this yet, but if there is some logic you think should stand by itself, feel free to 'hack' some draft functions. As an example, if you expect to have an operation to count jelly beans, you can put a simple placeholder for your function like this:

int CountJellyBeans() {
	// get the bunch of jelly beans
	// declare a counter variable and set it to zero
	// go to the first jelly bean
	// REPEAT THIS
	//     add one to the counter variable
	//     go to the next bean
	// REPEAT LAST STEP IF MORE BEANS
	// When no more beans return the counter
}

What kinds of functions?

Here are some functions you may want to build at some time or another:

  • calculate the apogee for a rocket launch
  • get the user's next move in the adventure game
  • draw the battleship map
  • generate a problem to solve
  • store the user's text in a file

There are any number of things that you can put into a function. As you go, I can help you set these up effectively.

Compile the file

And yes, again, the file still doesn't do anything. Compile it anyway.

Create a pull request to branch "C-add-empty-functions" for feedback

OPTIONAL You do not have to do this, but it could be a useful milestone for you, and allows me the opportunity to give you feedback when I can

Move on to your next step