Search

Program to Print Smallest Number of an Array - C, C++ Code

Write a C, C++ program to print smallest number of an array. Given an unsorted array, we have to write a code to print smallest number or element of an array.

To understand this problem, Let's take an array arr[] = {3, 4, 1, 5, 6}. The smallest number in an array is 1. Now the question is how to solve this problem. You can use multiple approaches to solve this problem.

METHOD 1 : Use Sorting Algorithm.

You can sort an array. After sorting an array pick the first element of an array, now the element at first position is smallest element of an array.