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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.