I dont understand how to make functions or how to get them to work? Please help
these are the directions
Function Name: display( )
Arguments: None
Return Value: None
Prototype: void display(void);
Action: Display name and lab number
Function Name: code_not_valid( )
Arguments: pay code (a char)
Return Value: true, if bad code; false, if good code
Prototype: bool code_not_valid(char);
Action: Use do/while loop in main to enter pay code
Test T/F value returned by function to see if another iteration is necessary
this is what i got so far
#include <iostream>
using namespace std;
// Begin main Function Definition
void code_not_valid(char);
void display(void);
#include <iostream>
usingnamespace std;
void function(); //Function prototype
int main()
{
function(); //Calling our other function in main
}
void function()
{
cout << "im in another function" << endl;
}
your code_not_valid() function is returning a different type then what you declared above main, and it takes a different argument list.
void code_not_valid(char);
bool code_not_valid()//should be code_not_valid(c);
you also have this function nested within the main function.
Think of functions as something external to the main. For example, the police serve a function by protecting people who are incapable of protecting themselves. If you have a problem, you call the police:
1 2 3
bool Crime;
if(Crime)
CallPolice(Crime);
in this case CallPolice(...) is a function that does something about crime.
if you were to put this into a semi working program: