You’ll need to use
* functions and parameters,
* the if command,
* The assignment and arithmetic operators
* Basic input and output
Design and implement a program that will accept up to twenty-five integers. You must include the following functions:
* An input function that fills the array
* A function that finds and displays the average of the even numbers in the collection.
* A function that finds and displays the average of the odd numbers in the collection.
Be sure to make the program easy to read and documented.
Write a C++ program?
and the problem is.........?
Reply:lolz, homework
Reply:Would you like me to design a GUI for that as well?
Reply:#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
const int size=25;
void input(int arr[])
{
for(int i=0;i%26lt;size;i++)
{
cout%26lt;%26lt;"\nEnter element in array";
cin%26gt;%26gt;arr[i];
}
}
void eaverage(int arr[])
{
int sum=0,k;
float average;
k=0;
for(int i=0;i%26lt;size;i++)
{
if(arr[i]%2==0)
{
sum=sum+arr[i];
k++;
}
}
average=sum/k;
cout%26lt;%26lt;"\nAverage of even numbers is:"%26lt;%26lt; average;
}
void oaverage(int arr[])
{
int sum=0,k;
float average;
k=0;
for(int i=0;i%26lt;size;i++)
{
if(arr[i]%2!=0)
{
sum=sum+arr[i];
k++;
}
}
average=sum/k;
cout%26lt;%26lt;"\nAverage of odd numbers is:"%26lt;%26lt; average;
}
void main()
{
clrscr();
int arr[size];
input(arr);
eaverage(arr);
oaverage(arr);
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment