Cpp2 Test1

The flashcards below were created by user slc53 on FreezingBlue Flashcards.

  1. Why do we modularize functions?
    Organize, compartmentalize, reduces the amount of code, easier for maintenance
  2. What is meant by the term black box?
    No need to know how a function works, only need to know input and output
  3. Give an example of a highly cohesive function.
    A function that does one task
  4. Can a function be coded inside main()?
  5. What does a name getAmountAndCalcTotalAndPrintValue tell you?
    2. not cohesive, probably has more than one task
  6. What is the void function format?
    • void functionName() // header
    • {
    • Stmt(s); //body of function
    • }
  7. what is the prototype format?
    void functionName(data types);
  8. What are some possible function calls?
    functionsName(parameters); or variable=functionName(parameters)
  9. what is a void function?
    1. a function that does not receive or return a value.
  10. what is a void returning function?
    1. a function that does not return a value.
  11. If the prototype is global, where does it appear in your code?
    Before main
  12. Given the following prototype: double getValidHours(); Write the statement that will call the function. Declare any variables you use.
    double hours=getValidHours();
  13. Given the function call: int age=getValidAge(); Write the prototype for the function.
    Int getValidAge();
  14. Given an example of a function that has a coupling problem?
    A function that receives parameters it doesn’t use
  15. 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);
  16. 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
  17. 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.
  18. 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');
  19. 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)
Card Set:
Cpp2 Test1
2016-05-26 11:36:00
Cpp2 Test1

Cpp2 Test1
Show Answers: