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

for each of the problems listed below write the c++ code 1. a program will read

ID: 3818692 • Letter: F

Question

for each of the problems listed below write the c++ code

1. a program will read ten numbers and store them in an array. the program should display how many of these elements are odd and how many are even.

2. a program will read ten numbers and store them in an array the program should then calculate the average and display how many of these numbers are below the average

3. a program will read six numbers and store them in an array. the program should then store the elements in reverse order in a second array and display the content of the first and second array

Explanation / Answer


//1. a program will read ten numbers and store them in an array. the program should display how many of these elements are odd and how many are even.

#include <iostream>
using namespace std;

void main()
{
int a[10],j,odd=0,even=0;

cout << "Enter enter 10 numbers: ";
   for(j=0; j<10; j++)
{
cin >> a[j];
}
  
for(j=0; j<10; j++)
{
if ( a[j] % 2 == 0)
       {
cout << a[j] << " is even.";
           ++even;
       }
else
   {
cout << a[j] << " is odd.";
       ++odd;      
       }
   }
   cout << " Total even numbers: " << even;
   cout << " Total odd numbers: " << odd;
}