C++ PRACTICAL PROGRAMS
Class 12 Computer Science | ASSEB
Program to find the smallest element of an array
#include<iostream>
using namespace std;
int main( )
{
int a[50], n, min;
cout<<”Enter number of elements”;
cin>>n;
cout<<”Enter array elements”;
for( int i=0; i<n; i++)
{
cin>>a[i];
}
min=a[0];
for( int i=1; i<n; i++)
{
if (a[i]<min)
min=a[i];
}
cout<<”\n Smallest element =”<<min;
return 0;
}
Output
Enter number of elements 5
Enter array elements 8
1
3
2
4
Smallest element = 1
QUICK LINKS
Class 11
Class 12
Previous Year Paper
Practical Programs