Wednesday, 22 November 2017

C++ Program to Find Minimum Element in an Array using Linear Search


Code:

#include   iostream

using namespace std;

int main()
{
int n, i, min, a[30]={89, 53, 95, 12, 9, 67, 72, 66, 75, 77, 18, 24, 35, 90, 38, 41, 49, 81, 27, 97, 111, 116, 854, 234, 658, 546, 987, 268, 946, 852};
char ch;
min = a[0];
cout<<"\nThe data element of array:";

for(i = 1; i < 30; i++)
{
cout<<" "<
// Assign min to the current element if its value is lesser than min value.
if(min > a[i])
min = a[i];
}
cout<<"\n\nMinimum of the data elements of array using linear search is: "<

    return 0;
}


Output:

The data element of array: 89 53 95 12 9 67 72 66 75 77 18 24 35 90 38 41 49 81 27 97 111 116 854 234 658 546 987 268 946 852

Minimum of the data elements of array using linear search is: 9


More C++ Programs:















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...