2012-12-28T04:22:01-05:00
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.
1
2012-12-28T05:17:37-0500
#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 !
Learn more about our help with Assignments:
C++
Comments