Homework 3
Note there are three parts here: part A, B, C.
Part A. Identify which of the following are legal variable names. For those that are not legal, indicate why.
Part B. The purpose of this homework is to ensure you have installed Visual C++ 2005 Express Edition. Do not worry if you do not understand everything you are typing; it will be explained as the course progresses. This part is designed to be completed ON YOUR OWN MACHINE IN BANCROFT after Lab 1. Do the following:
1. Complete steps 1-5 of lab 1.
2. In place of step 6 copy the following code:
#include <iostream>
int main () {
std::cout << "Midn YOURNAMEHERE YOURALPHAHERE installed express
2005 correctly!" << std::endl;
return 0;
}
Obtaining a Screen Shot:
1. Click anywhere on the display containing program
output.
2.
Press
Alt-printscreen to “capture the screen shot”
3.
Open microsoft
paint start -> all programs -> accessories -> paint
4.
Paste the image
into paint by selecting edit -> paste
5.
Print the image
by selecting file -> print. OR you
can paste into Microsoft Word and use that.
Part C: Copy and paste the following program into the Microsoft Visual C++ and compile. Examine the errors generated by the compiler, then FIX each error. Turn in a printout of the source code for your (fixed) program AND a printout of the screenshot showing your program running.
// cents.cpp
// Convert nickels and dimes to cents.
#include <iostream>
using namespace
std;
int main()
{
int nickels, dimes, cents;
nickels = 3;
Dimes = 7;
cents = 5 * nickels + 10 * dimes;
cout << nickels << "
nickels and ";
cout << dimes << " dimes
" << endl;
cout << "= "
<< cents << " cents "
return 0;
}