New, need guidance

Problem:
Write a program that prompts the user to enter some number of 1, 2, 5, 10, 20, 50 and 100 dollar bills. Query the user separately for the number of each size dollar.

I think I've completed the code pretty well but the last part of the question states:
Modify your program to use an initializer list for the vector, and use a range-based for statement to traverse the vector. Note: These C++11 features are available in g++-4.6 and Visual Studio 2012, but may not be available on other compilers.

I don't understand what the last part is asking. Hopefully someone here can explain it to me.

Any critique on my code format would also be great!

Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "std_lib_facilities_3.h"
vector<int>bills;
	int bill;
int bill_tot(){
		int sum = 1*bills[0]+2*bills[1]+5*bills[2]+10*bills[3]+20*bills[4]+50*bills[5]+100*bills[6];
		return sum;
	}
int main()
try{
	cout << "Enter the number of One Dollar Bills you have: ";
	cin >> bill;
	cout << '\n';
	bills.push_back(bill);
	if (bill<0)
		error("You can't have a negative value.\n");

	cout << "Enter the number of Two Dollar Bills you have: ";
	cin >> bill;
	cout << '\n';
	bills.push_back(bill);
	if (bill<0)
		error("You can't have a negative value.\n");

	cout << "Enter the number of Five Dollar Bills you have: ";
	cin >> bill;
	cout << '\n';
	bills.push_back(bill);
	if (bill<0)
		error("You can't have a negative value.\n");

	cout << "Enter the number of Ten Dollar Bills you have: ";
	cin >> bill;
	cout << '\n';
	bills.push_back(bill);
	if (bill<0)
		error("You can't have a negative value.\n");

	cout << "Enter the number of Twenty Dollar Bills you have: ";
	cin >> bill;
	cout << '\n';
	bills.push_back(bill);
	if (bill<0)
		error("You can't have a negative value.\n");

	cout << "Enter the number of Fifty Dollar Bills you have: ";
	cin >> bill;
	cout << '\n';
	bills.push_back(bill);
	if (bill<0)
		error("You can't have a negative value.\n");

	cout << "Enter the number of One Hundred Dollar Bills you have: ";
	cin >> bill;
	cout << '\n';
	bills.push_back(bill);
	if (bill<0)
		error("You can't have a negative value.\n");
	

	cout << "You have " << bills[0] <<" One Dollar Bills.\n";
	cout << "You have " << bills[1] <<" Two Dollar Bills.\n";
	cout << "You have " << bills[2] <<" Five Dollar Bills.\n";
	cout << "You have " << bills[3] <<" Ten Dollar Bills.\n";
	cout << "You have " << bills[4] <<" Twenty Dollar Bills.\n";
	cout << "You have " << bills[5] <<" Fifty Dollar Bills.\n";
	cout << "You have " << bills[6] <<" One Hundred Dollar Bills.\n";
	cout << "The value of all your Dollar Bills are $" << bill_tot() << endl;
	keep_window_open();
}
catch (runtime_error e) {	
	cout << e.what() << '\n';
	keep_window_open();
}
Look at the page http://www.cplusplus.com/articles/EzywvCM9/
You will see Range-based for() and Initializer lists explained.
Topic archived. No new replies allowed.