Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Why won\' t my program work ? I need to tell the program to give 10 numbers and

ID: 3686394 • Letter: W

Question

Why won' t my program work ? I need to tell the program to give 10 numbers and put them in reverse.

#include <iostream>

#include <cmath>

#include <omainp>

using namespace std;

int main()

{

const int num = 10;

int j = num - 1;

int i, move, list[num], total = 0;

for (i = 0; i < num; i++)

{

cout << "Enter ten numbers : ";

cin >> list[i];

}

int temp;

for (int i = 0; i < j/2; i++)

{

temp = list[i];

list[i] = list[j - i];

list[j - i] = temp;

}

for (i = 0; i > num; i++)

{

cout << " " << list[i];

}

system("pause");

return 0;

}

Explanation / Answer

Please find the corrected code below:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
const int num = 10;
int j = num - 1;
int i, move, list[num], total = 0;
cout << "Enter ten numbers : ";
for (i = 0; i < num; i++)
{
cin >> list[i];
}
int temp;
for (int i = 0; i < j/2; i++)
{
temp = list[i];
list[i] = list[j - i];
list[j - i] = temp;
}

for (i = 0; i < num; i++)
{
cout << " " << list[i];
}
system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote