Even odd Number

import 'dart:io';//1

main(List<String> arguments) {
  print('Enter a Integer Number'); //2
  var name = stdin.readLineSync();//3
  var number = int.parse(name);//4
  if(number%2==0)//5
    {
      print("Enter Number is $number is Even");//6
    }
   else
     {
       print("Enter Number is $number is Odd");//7
     }

}
  1. import statement for input and out-stream lib for Dart
  2. Instruct to user enter two number
  3. Take First input and assign to name variable
  4. Convert name variable to int and assign to number variable
  5. Check if statement for even and odd number
  6. if enter number is even then executed this line and print the result
  7. if enter number is odd then executed this line and print the result

Output

Enter an Integer Number
89
Enter Number is 89 is Odd

Enter a Integer Number
20
Enter Number is 20 is Even

Leave a Reply

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