I received help here from experts nice enough to help me out so i am posting all my assignments.. Maybe someone will find the useful and leave from them.
Basic, for beginners.
question: Create an EvensAndOdds application that generates 25 random integers between 0 and 99 and then
displays all the evens on one line and all the odds on the next line. Application output should look similar
to:
ODD: 21 21 87 39 45 7 75 71 87 9 81 27 57
EVEN: 26 64 2 74 0 40 84 0 82 0 32 90
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main ()
{
const int arrSize = 25;
int array[arrSize];
srand (time (0));
for (int i = 0; i < arrSize; i++) // Loop to generate 25 numbers between 0 and 99
{
array[i] = (rand () % 100);
}
cout<< "Random Numbers are: ";
cout<< endl << endl;
for (int i = 0; i < arrSize; i++)
{
cout<< array[i] << " "; // displays all the random numbers generated
}
cout <<"\n\n";
system ("PAUSE");
system ("CLS");
cout<< "ODD: ";
for (int i = 0; i < arrSize; i++) // Odd Numbers Loop
{
if (array[i] % 2 != 0) // checking for odd numbers
{
cout<< array[i] << " "; // displays all odd numbers
}
}
cout << "\n\n";
cout << "EVEN: ";
for (int i = 0; i < arrSize; i++) // Even number loop
{
if (array[i] % 2 == 0) // checking for even numbers
{
cout<< array[i] << " "; // didplays all even numbers
}
}
cout << "\n\n";
// End of program
system ("PAUSE");
return 0;
}