how to find smallest number in array in c++
#include<iostream>
using namespace std;
main()
{
cout<<"enter 10 numbers for find smallest number from 10 numbers\n";
int a[10],i;
for(i=0;i<10;i++)
cin>>a[i];
int small=a[0];
for(i=0;i<10;i++)
if(a[i]>a[i+1])
small=a[i+1];
cout<<"smallest number is\n";
cout<<small;
}
No comments:
Post a Comment