Lesson 17 Using Functions
Lesson 17 Using Functions
I.E
.......................................................
void foo()
{
cout << "Hellow , world!\n";
int main ()
{
// call our function
..............................................................
..............................................................
PART 2: FUNTIONS THAT CAN ACCEPT ARGUMENTS
#include <iostream>
#include <string>
using namespace std;
int main()
{
// call the function and pass it a string "argument"
// a literal or a variable can be an argument
//Another example would be one that accepts two or more integers as its only
parameters
int main ()
{
// call foo and passs it two integer arguments
foo (8, 3);// 8 will be passed to x and 3 to y and therefore execute the code
in the body function as addition
}
...................................................................................
...................................................................................
...................................................................................
......................................................
EXCERCISES STRUCTURE
Libraries to include
#include <ctime>
#include <cstdlib>
//initialize error to the max parameter and bestGuess to the lowest parameter