Ok so heres the idea. She gives us a specified input and output, and we have to create the program that reads in the 5 values into an array and sorts them to reach the output. Simple enough as we have done plenty of these, but i cant figure out this pattern. The program below works but we cant use direct assignments, how is she getting this output????
Input: 3, 15, 34, 21, 84
Output: 0, 100, 100, 100, 100
My code:
Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
const int ARRAY_MAX = 5;
int main(int argc, char* argv[])
{
int intArray[ARRAY_MAX];
int temp;
for (int i = 0; i < ARRAY_MAX; i++)
{
cout << "Enter an int value: ";
cin >> intArray[i];
}
for (int j = 0; j < ARRAY_MAX; j++)
{
if (intArray[j] < 10)
{
intArray[j] = 0;
}
else
{
intArray[j] = 100;
}
cout << intArray[j] << endl;
}
return 0;
}