C++ Chapter 1: Introduction to Computer and C++ Programming

  1. What are the 5 main components of a computer?
    Input devices, output devices, the processor, main memory, and secondary memory.
  2. What would be the data for a program to add 2 numbers?
    The 2 numbers to be added.
  3. What would be the data for a program that assigns letter grades to students in a class?
    The grades for each student on each test and each assignment.
  4. What is the difference between a machine-language program and a high-level language program?
    A machine-language program is a low-level language program consisting of 0s and 1s that the computer can directly execute. A high-level language is written in a more English-like format and is translated by a compiler that the computer can directly understand and execute.
  5. What is the role of a compiler?
    A compiler translates a high-level language program into a machine-language program.
  6. What is a source program? What is an object program?
    The high-level language program that is input to a compiler is called the source program. The translated machine-language program that is output by the compiler is called the object program.
  7. What is an operating system?
    It is a program or several cooperating programs but is best thought of as the user's chief servant.
  8. What purpose does the operating system serve?
    To allocate the computer's resources to different tasks the computer must accomplish.
  9. Name the OS that runs on the computer you use to prepare programs for this course.
    Possibilities are Mac OS, Windows, VMS, Solaris, SunOS, and UNIX.
  10. What is linking?
    The object code for your C++ program must be combined with the object code for routines (such as input/output routines) that your program uses. This process of combining object code is called linking.
  11. Find out whether linking is done automatically by the compiler you use for this course.
    Most UNIX compilers link automatically as do the compilers in most IDEs for Windows and Macs.
  12. What is the first step you should take when creating a program?
    Be certain that the task to be accomplished by the program is completely and precisely specified.
  13. The program design process can be divided into 2 main phases. What are they?
    The problem-solving phase and the implemenation phase.
  14. Explain why the problem-solving phase should not be slighted.
    The 2 phase process produces a correctly working program faster.
  15. If the following statement were used in a C++ program, what would it cause to be written on the screen?

    cout << "C++ is easy to understand.";
    C++ is easy to understand.
  16. What is the meaning of \n as used in the following statement?

    cout << "Enter the number of peas in a pod:\n";
    The symbols \n tell the computer to start a new line in the output so that the next item output will be on the next line.
  17. What is the meaning of the following statement?

    cin >> peas_per_pod;
    This statement tells the computer to read the next number that is typed in at the keyboard and to send that number to the variable named peas_per_pod.
  18. What is the meaning of the following statement?

    total_peas = number_of_pods * peas_per_pod;
    This statement says to multiply the 2 numbers in the variables number_of_pods and peas_per_pod and to place the result in the variable named total_peas.
  19. What is the meaning of this directive?

    #include <iostream>
    It tells the compiler to fetch the file iostream. This file contains declarations of cin, cout, the insertion (<<), and extraction (>>) operators for I/O. This enables correct linking of the object code from the iostream library with the I/O statements in the program.
  20. What, if anything, is wrong with the following #include directives?
    a: #include <iostream >
    b: #include < iostream>
    c: #include <iostream>
    a: The extra space after iostream file name cause a file-not-found error message.

    b: The extra space before the iostream file name causes a file-not-found error message.

    c: Correct
  21. What are the 3 main kinds of programs errors?
    Syntax, run-time, and logic errors.
  22. What kinds of errors are discovered by the compiler?
    Syntax errors.
  23. If you omit a punctuation symbol (such as semicolon) from a program, an error is produced. What kind of error?
    A syntax error.
  24. Omitting the final brace } from a program produces an error. What kind of error?
    A syntax error.
Author
senator77
ID
127923
Card Set
C++ Chapter 1: Introduction to Computer and C++ Programming
Description
C++ Chapter 1: Introduction to Computer and C++ Programming
Updated