- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the program below, we've introduced beginers to programming in C++
Source Code: Find Smallest Element in Array in c++
/* C++ Program - Find Smallest Element in Array (Linear Search -Data Structures)*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int small, arr[50], size, i;
cout<<"Enter Array Size (max 50) : ";
cin>>size;
cout<<"Enter array elements : ";
for(i=0; i<size; i++)
{
cin>>arr[i];
}
cout<<"Searching for smallest element ...\n\n";
small=arr[0];
for(i=0; i<size; i++)
{
if(small>arr[i])
{
small=arr[i];
}
}
cout<<"Smallest Element = "<<small;
getch();
}
Output
Enter Array Size (max 50) :10
Enter array elements :
1
3
2
5
4
6
8
7
9
12
Searching for smallest number ...
smallest Number = 1