Swift Odd or Even

Swift odd or even program will help you to find the number is odd or even number in swift. To find the number is odd or even we must initialize the value before the condition like here we have initialized the value n=5, to check the number is odd or even in swift programming language

Swift Odd or Even

Swift odd or even program for beginners, A number that can be divided into two equal classes is called an even number. 

A number that cannot be split into two equal classes is called an odd number. 

Using if else statement in this program it will execute the condition whether it is safisfied the condition to print the output.

Odd and Even Number

Odd numbers are those that end in 1,3,5,7, or 9, whereas even numbers are those that end in 0,2,4,6, or 8. 

Numbers like 13, 25, 37, 49, and so on are odd numbers, while numbers like 22, 34, 70, 68, and so on are even numbers. 

A number that can be divided into two equal groups is called an even number. 

A number that cannot be divided into two equal groups is called an odd number. 

Even numbers, regardless of how many digits they have, end in 2, 4, 6, 8, and 0; 

we know the number 5,917,624 is even because it ends in a 4! 

Odd numbers have endings of 1, 3, 5, 7, and 9.

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

Output:

5 is odd