expand icon
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
Exercise 2
In this exercise, assume you have written a C++ program and stored your source code in a file named MyCPlusPlusProgram.cpp. Answer the following questions:
What command would you use to compile the source code?
Explanation
Verified
like image
like image
Compiling C++ program:
Compiler is a program, which covert source code of a program into executable code in following two steps:
• First, object code is generates from source code with the same file name but with the extension ".obj".
o The extension of source code of C++ program is ".cpp".
• Then, the object code is linked with executable code and the file is created with same file name but with the extension ".obj".
• Name of the visual C++ compiler is "cl" and it both a compiler and linker.
The following is the command to compile the C++ program in visual C++:
cl program_name.cpp
Here,
• "cl" represents the compiler
• "program_name.cpp" represents file name
Note: Execute the program in the Developer command prompt for VS2012 and change the file path to the path, where the source code file resides.
Executing C++ program:
A C++ program can be executed as soon as compiling it.
The following is command to execute C++ program in visual C++:
program_name
Here,
• "program_name" represents file name
Note: Ensure that the ".exe" file of source code is created in same directory.
The command use to compile source code "MyCPlusPlusProgram.cpp":
cl MyCPlusPlusProgram.cpp
Here,
• "cl" represents the compiler
• "MyCPlusPlusProgram.cpp" represents file name
The command use to execute the program:
MyCPlusPlusProgram
Here,
• "MyCPlusPlusProgram" the file name
close menu
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
cross icon