Smaller Number of an Array

import "dart:io";//1
main()
{
  print("Enter the Size of Array");//2
  var size = int.parse((stdin.readLineSync()));//3
  var numbers=List(size);//4
  for(int i=0;i<size;i++)//5
  {
    numbers[i]=int.parse(stdin.readLineSync());//6
  }
  var mininum = numbers[0];//7
  for(int i=0;i<numbers.length;i++)//8
  {
    if(mininum>numbers[i])//9
    {
      mininum = numbers[i];//10
    }
  }

  print("Minimum Number of Given Array is=$mininum");//11
}
  1. Import statement for input and output library
  2. Instruct the user to enter the size of the array
  3. After converting user input into an int and then assigned to size variable
  4. Create a new array(List ) of user-entered size with a variable name numbers
  5. Execute for loop from 0 to less than numbers length
  6. After converting user input into int and then assigned to the element of an array (initialization of Array Elements based on user input)
  7. Create and initialized and minimum variable with the first element of an array
  8. Execute for loop from 0 to less than numbers length to find the smaller number from array elements
  9. if condition to find smaller number from an array
  10. Update the greater number based on condition
  11. Print the number smaller number on the console

Output

Enter the Size of Array
10
2
6
78
8909
23
56
67
23
45
67
Minimum Number of Given Array is=2

Leave a Reply

Your email address will not be published. Required fields are marked *