how to Rearrange the code to find and print the smallest element of the array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to Rearrange the code to find and print the smallest element of the array

28th Oct 2016, 3:18 PM
sundar
sundar - avatar
2 Answers
+ 9
1. Assign arr[0] as a minimum 2. Traverse through the whole array 3. If an element is less than the current minimum, then make that element the minimum min=arr[0]; for(int i=0;i<arr.length;i++) { if(arr[i]<min) min=arr[i] } cout<<min<<endl;
28th Oct 2016, 3:47 PM
Remmae
Remmae - avatar
0
how print the i love you word in c++
17th Nov 2016, 5:39 AM
AKSHAY SONAWANE
AKSHAY SONAWANE - avatar