-
Why do we modularize functions?
Organize, compartmentalize, reduces the amount of code, easier for maintenance
-
What is meant by the term black box?
No need to know how a function works, only need to know input and output
-
Give an example of a highly cohesive function.
A function that does one task
-
Can a function be coded inside main()?
no
-
What does a name getAmountAndCalcTotalAndPrintValue tell you?
2. not cohesive, probably has more than one task
-
What is the void function format?
- void functionName() // header
- {
- Stmt(s); //body of function
- }
-
what is the prototype format?
void functionName(data types);
-
What are some possible function calls?
functionsName(parameters); or variable=functionName(parameters)
-
what is a void function?
1. a function that does not receive or return a value.
-
what is a void returning function?
1. a function that does not return a value.
-
If the prototype is global, where does it appear in your code?
Before main
-
Given the following prototype: double getValidHours(); Write the statement that will call the function. Declare any variables you use.
double hours=getValidHours();
-
Given the function call: int age=getValidAge(); Write the prototype for the function.
Int getValidAge();
-
Given an example of a function that has a coupling problem?
A function that receives parameters it doesn’t use
-
Write a function called printNumbSquared that will print a number passed to it times itself. 3. Write the prototype for printNumbSquared function.
- void printNumbSquared (int number)
- {
- cout << number*number;
- }
- 3. void printNumbSquared (int);
-
Other Boolean functions that are useful
- bool isalpha(char); checks if char is A-Z or a-z
- bool isalnum(char); checks if A-Z,a-z or 0-9
- bool isdigit(char); checks if 0-9
- bool islower(char); checks if lower case
- bool isupper(char); checks if upper case
-
What must be done in VS to open a file?
In the Solution Explorer, right click on Resources Files. Add a new item as text file (.txt). Call it dates.dat.
-
What code is needed to work with files?
- ifstream fin("dates.dat");
- #include
- if (!fin.is_open())
- {
- cout << "file dates.dat could not open" << endl;
- system("pause");
- exit(-1);
- }
- getline(fin, name);
- if (fin.eof())
- fin >> gender >> age;
- fin.ignore(80, '\n');
-
function header, call, prototype look like
- int addAtStart(string[], char[], int[], int);
- length = addAtStart(name, gender, age, length);
- int addAtStart(string name[], char gender[], int age[], int length)
|
|