For the purpose of writing programs in C++, it is going to be involving doing some simple calculations. It will be about performing the circumference of a circle.
#1: Basic understanding of the structure in a C++ program.
#2: Mathematics because it is going to be necessary to do calculations.
#3: A program that can be used to not only write the code but also compile and execute as well.
#4: The different data types that exist such as integer, double, float, and so forth.
#1: The formula is C = PI * D or C = 2 * PI * R.
#2: It can be written in two different formats. There will be two versions shown, which will demonstrate how it can be written with a function and without.
#3: Make sure to use the double format because it will be dealing with decimals.
#4: For the purpose of programming and finding the circumference of a circle, have pie equal 3.14. While it is an approximation, it can work for the purpose needed.
Writing the program
Step 1: Go to start and immediately look for the program that you use to write the program in. That would be like Visual Studio.
Step 2: Go to new project and select Visual C++. Once inside that part, go to the template Win32 Console Application. Name it whatever you want. Have it as an empty project.
Step 3: Create a source file since it is the only item that is going to be needed in order to get the job done.
Step 4: Write the code out completely. Check the screen shots below to get a look at the code.
Figure 1: Without another function.
Figure 2: Writing it with a function.
Step 5: Double check everything with the code from top to bottom. See if you can spot any potential errors should they arise.
Step 6: Build the program written. It will be the area that will check for errors and/or warnings. Warnings are not going to cause the program to not compile whatsoever.
Step 7: If there are errors, correct them immediately. After doing that, go back to step 6 and try again. If there are no errors, go to the final step.
Step 8: Run the program directly. Doing so will have the executable ready and can be accessed at any time as it will be able to be opened up completely.
Congratulations, you have successfully written a program to calculate the circumference of a circle.