Write a program to find the smallest element of the given array

//this is a program to find the smallest element of the given array
#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
int a[5],i,small;

cout<<"\n\nENTER THE ELEMENTS OF THE ARRAY: ";
for(i=0;i<5;i++)
{
cout<<"\nEnter any number: ";
cin>>a[i];
}

//displaying the array elements
cout<<"\n\nDisplaing the array elements: ";
for(i=0;i<5;i++)
cout<<" "<<
a[i];

//searching the smallest element
small=a[0];
for(i=0;i<5;i++)
{
if(small>a[i])
small=a[i];
}

cout<<"\n\nThe smallest element is "<<small;

return 0;
}

Previous
Next Post »