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

Write a program that allows the user to enter an integer n, and then generates n

ID: 3779480 • Letter: W

Question

Write a program that allows the user to enter an integer n, and then generates n random numbers between 0 and 100. The program calculates and prints the sums for even and odd numbers. Draw the flowchart for the program on the hack of this paper. Open Text Pad and save the source tile on the desktop using the file name as lastname_final Write your name on the first line of the source file, and short comment for each task in the program. Leave the Text Pad open and this paper on the keyboard when you finish the exam. Here is an example of output screen:

Explanation / Answer

#include<stdio.h>
#include<iostream>
int main()
{
   int i,num,array[100];//array used to store the values
   std::cout <<"Enter the integer---->";//enter the numbers

std::cin>>num;//read the numbers
   std::cout<<"There are "<<num<<" Random numbers in the array"<<std::endl;

for (i = 0; i < num; i++)
{
std::cin>> array[i];//store which we values we are enter

}

int sume=0,counte=0;;//counte is used to print the no of even values...sum is preform add the even values

for (i = 0; i < num; i++)
{
if(array[i] % 2 == 0)
{ sume=sume+array[i];
counte++;

}
  
  
}
std::cout<<counte<<" of the"<<num<<" even numbers "<<std::endl;//print the even numbers

for (i = 0; i < num; i++)
{
if(array[i] % 2 == 0)
{
std::cout<<array[i]<<" ";  
}
  

}
std::cout<<"Even sum of even numbers is- "<<sume;
std::cout<<" ";

  

int sumo=0,counto=0;//counte is used to print the no of even values...sum is preform add the even values
for (i = 0; i < num; i++)
{
if (array[i] % 2 != 0)
{sumo=sumo+array[i];
counto++;

}
}
std::cout<<counto<<" of"<<num<<"numbers in the array are ";//print the odd numbers
for (i = 0; i < num; i++)
{
if (array[i] % 2 != 0)
{
std::cout<<array[i]<<" ";
}
}
std::cout<<" Odd numbers in the array are -"<<sumo<<std::endl;
  
}

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