Need help adding appropriate comments to program.

I need some help completing this assignment by adding appropriate comments to the program. Thanks for the help.

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
  #include <iostream>

	using namespace std;
	void printArray(const double a[], int n){
	for(int i=0; i<n; i++){
	if(i % 10 == 0){
	cout<<endl;
	}
	cout<<a[i]<<" ";
	}
	cout<<endl;

	}
	void swap(double a[], int x, int y){
	int c = a[x];
	a[x] = a[y];
	a[y] = c;
	}
	void reverse(double a[], int n){
	for(int i=0; i<n/2; i++){
	swap(a,i,n-1-i);
	}
	}
	int main()
	{
	double array[54];
	for(int i=0; i<27;i++){
	array[i] = i *i;
	}
	for(int i=27; i<54;i++){
	array[i] = 3 * i;
	}
	cout<<"Array elements before reverse: "<<endl;
	printArray(array, 54);
	reverse(array, 54);
	cout<<"Array elements after reverse: "<<endl;
	printArray(array, 54);

	return 0;
	}
if you wrote the program yourself just put down your thoughts next to the code why you wrote it the way you did - this would be a first draft of comments and then you can polish it up further as you wish
Topic archived. No new replies allowed.