Find Greater Number of 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 greaterNumber = numbers[0];//7
  for(int i=0;i<numbers.length;i++)//8
  {
    if(greaterNumber<numbers[i])//9
    {
      greaterNumber = numbers[i];//11
    }
  }

  print("Greater Number of Given Array is=$greaterNumber");//12
}
  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 greaterNumber variable with the first element of an array
  8. Execute for loop from 0 to less than numbers length to find the greater number from array elements
  9. if condition to find greater number from an array
  10. Update the greater number based on condition
  11. Print the number Greater number on the console

Output

Enter the Size of Array
5
34
67
89
345
567
Greater Number of Given Array is=567

Leave a Reply

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