60 465
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #21349 in C++ for Candice Battle

Question #21349
Input a list of positive numbers, terminated by 0, into an array Numbers [ ]. Then display the array and the largest and smallest number in it.
Expert's answer

#include <iostream>
#include "conio.h"

using namespace std;

double FindMax(double aray[],int length)//Bubble sort function
{
int i;
double max;
max=aray[0];
for(i=0;i<length;i++)
{
if(max<aray[i]){
max=aray[i];
}
}
return max;
}
double FindMin(double aray[],int length)//Bubble sort function
{
int i;
double min;
min=aray[0];
for(i=0;i<length;i++)
{
if(min>aray[i]){
min=aray[i];
}
}
return min;
}
int main()
{
int n;
double array1[100];
cout<<"Enter the number of elements : ";
cin>>n;
for(int i=0;i<n;i++){
cout<<"Enter the "<<i+1<<" element : ";
cin>>array1[i];
}
cout<<"Max element is "<<FindMax(array1,n);

cout<<"
Min element is "<<FindMin(array1,n);

cout<<"
Press any key to exit....";
getch();

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions