CSC- Chapter 2 Quiz Questions

  1. The text of a comment can be...
    anything the programmer wants to write.
  2. A preprocessor directive starts with #. Preprocessor directives are carried out _______
    just before a program is processed by the compiler.
  3. Every C++ program must contain a _____ function.
    main
  4. Rearrange the following code so that it forms a correct program that prints out the letter Q:

    int main()
    }
    // A SCRAMBLED program
    return 0;
    #include <iostream>
    cout << "Q";
    {
    using namespace std;
    • 1 //A SCRAMBLED program
    • 2 #include <iostream>
    • 3 using namespace std;
    • 4 int main ()
    • 5 {
    • 6 cout << "Q";
    • 7 return 0;
    • 8 }
  5. Write a statement that prints Hello World to the screen
    1 cout <<"Hello World";
  6. Suppose your name was Alan Turing. Write a statement that would print your last name, followed by a comma, followed by your first name.
    1 cout << "Turning,Alan";
  7. The word in the brackets of an include directive specifies
    a file containing code that is copied into the program at that point.
  8. Write the include directive needed to allow use of the various I/O operators such as cout and cin.
    1 #include <iostream>
  9. Write a statement that declares an int variable named count.
    • 1 int count;
    • 2 cout <<count;
  10. Write a statement that declares an int variable named count.
    • 1 int count;
    • 2 cout <<count;
  11. Declare an int variable named degreesCelsius.
    1 int degreesCelcius;
  12. Which of the following is NOT a legal identifier?

    _
    7thheaven
    outrageouslyAndShockinglyLongRunon
    lovePotionNumber9
    _42
    7thheaven (Can't start with a number)
  13. Which of the following IS a legal identifier?

    Five_&_Ten
    LovePotion#9
    _________
    "Hello World"
    5_And_10
    ____________
  14. Which is the best identifier for a variable to represent the amount of money your boss pays you each month?
    monthlyPay
Author
GoBroncos
ID
364153
Card Set
CSC- Chapter 2 Quiz Questions
Description
Updated