12:20 PM
Check number is even or odd swift
var i : Int = 5
if (i%2==0) {
print("\(i) is even number")
}
else{
print("\(i) is odd number")
}
var i : Int = 5
if (i%2==0) {
print("\(i) is even number")
}
else{
print("\(i) is odd number")
}
func prime(n: Int){
var count = 0
for i in 1...n
{
if(n%i==0)
{
count+=1
}
}
if(count==2)
{
print(" Prime number \(n)")
}
else
{
print("Prime Not Number\(n)")
}
}
for j in 1...20
{
prime(n:j)
}
var str = "Pratik"
var str1 = String(str.reversed())
if (str == str1)
{
print("String is Palidrome")
}
else
{
print("String is Not Palidrome")
}
var str = "aba"
var str1 = String(str.reversed())
if (str == str1)
{
print("String is Palidrome")
}
else
{
print("String is Not Palidrome")
}