Here is the program:
int i,n;
double v_in[20+1],v_out[20+1];
cout << "\ninput n ? ";
cin >> n;
for(i=1;i<=n;i++) {
cout << "input v_in[" << i << "] ? ";
cin >> v_in[i];
}
// reverse v_in and store the result in v_out
for(i=1;i<=n;i++) {
v_out[i] = v_in[n-i+1];
}
cout << "\nn = " << n;
cout << "\n\nv_in = ";
for(i=1;i<=n;i++) {
cout << "\n" << v_in[i];
}
cout << "\n\nv_out = ";
for(i=1;i<=n;i++) {
cout << "\n" << v_out[i];
}
cout << "\ndone.\n";
getch();
return 0; }
Now in the Section in Bold, there's a part where he does thisv_out[i] = v_in[n-i+1]
What is the significance of n-i+1
?? How does this reverse v_in???
Please help??