c++ program to find minimum number in an array

#include <iostream>                    
using namespace std;                   Download C++ Minimum Number
int main()  {

 int min;
 int ary[5];

 for(int i=1;i<6;i++)
 {
 cout<<"Enter "<<i<<" element of array :";
 cin>>ary[i];
 }

  for (int j=1;j<6;j++)
   {
     if (ary[j]<ary[j+1])
       {
       min=ary[j];
       }
     else
       {
       min=ary[j+1];
       }

   }

 cout<<"min : "<<min<<endl;
 system("pause");

return 0;

 }

No comments:

Post a Comment