VC++ Programm Analysis

In this lesson, you learned about the fundamental format of all C++ programs. You saw the following: 

  • Visual C++ programs contain a main() function. 

  • Braces determine where the main() function begins and ends. 

  • Preprocessor directives direct the way Visual C++ compiles your program. Preprocessor directives always begin with a pound sign, #. The #include directive includes files needed by library functions. 

  • Visual C++ comments begin with // and end at the end of the line. Comments are for people, not for Visual C++. 

  • The cout command outputs data to your screen. 

  • All characters are important in Visual C++ programs. 

Project 2 Listing. Introduction to Visual C++ programs. 

1:  // Filename: PROJECT2.CPP  2:  // Introduces the format of Visual C++ programs and demonstrates  3:  // how to write Visual C++ comments, the #include preprocessor  4:  // directive, and the cout command that outputs data to the  5:  // screen.  6:  7:  #include   8:  9:  void main()  10:  {  11:    cout << "I have a ";  12:    cout << "Sleekster";       // Continues the output line  13:    cout << " automobile.";      14:    cout <<>


1: A Visual C++ comment that includes the program's filename.

2: A comment that begins the introduction of the program's description.

3: The program's description continues.

4: The program's description continues.

5: The program's description continues.

6: Extra blanks make your program more readable.

7: The cout command needs information in the IOSTREAM.H header file.

8: Extra blanks make your program more readable.

9: All functions have names and the first function in all Visual C++ programs is main().

10: All functions begin with a left brace.

11: The screen output begins.

12: The car's model name prints. No new line occurs.

13: Finish the output.

14: Move the cursor down two lines.

15: Extra blanks make your program more readable.

16: Another message prints.

17: cout prints all kinds of data. Strings and an integer output here.

18: This cout outputs strings and a character literal.

19: Statements can be more than one line.

20: Extra blanks make your program more readable.

21: The final return; in main() always returns control back to Visual C++'s QuickWin window

22: A closing brace always terminates the main() function.

7: The compiler inserts a helpful file here. 

10: void means that main() does not return a value to the operating system. 

14: endl sends a new line command to the screen.


      I have a Sleekster automobile.  I want to sell my car for $4800 (cheap!).  I have had the car for 5 years.  It's really a grade-A deal!

No comments: