Simple Visual C++ Program

Enter and run a simple Visual C++ program and discuss the code and results. 

Here is a Visual C++ program. Although it is extremely simple, it contains all the elements necessary to be a valid Visual C++ program. 

// Filename: CFIRST.CPP  // Program displays a message on-screen  #include   void main()    {      cout << "I will be a C++ expert!";    }

Even a simple Visual C++ program might intimidate a beginning programmer. Do not let it intimidate you! C++ has a bark that is often worse than its bite. If you were to type this program into your Visual C++ compiler's editor, compile it, and run it, you would see the following output on your screen: 

I will be a C++ expert!

At this point, do not concern yourself with the specifics of the code in this program. The rest of this book explains things like that. Only one line in the entire seven-line program does anything noticeable (the one that begins with cout), and the rest of the program is simply there because C++ needs it to be there. You will find out why as you work through the unit. 

The preceding program contains a total of seven lines, and only one really produces something you can see. More advanced Visual C++ programs might consist of 500 lines or more. That 7-to-1 setup-to-work ratio does not exist for every Visual C++ program. That would cause too much work on your part! The amount of code that sets up the program diminishes as a program grows. 

C++ programs sometimes look cryptic, but when you learn the fundamentals of the language, you'll see that program formats are often similar. A simple program might contain several lines of code. 

There are no Stop and Type parts in this unit due to the textual nature of the material. 

No comments: