Write a program in swift to check the number is even or odd.

      Code:

import UIKit

var n = 28 // enter your number here

if(n%2==0)
{
    print("\(n) is even number.")
}
else
{
    print("\(n) is odd number.")
   
}

Result:




1 comments:

  1. Nice article . you can use & operator for checking even or odd any number reference check even or odd without modulo

    ReplyDelete