You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Q10) Write a Function to Check whether the given Number is Even or Odd
#! /bin/basheven_odd()
{
n=$1if [ $((n %2))-eq 0 ];thenecho"$n is an Even Number"elseecho"$n is an Odd Number"fi
}
read -p "Enter Any Number to test whether it is Even or Odd: " n
even_odd $n
Q11) Write a Function to Test whether the given Number is Positive or Negative
#! /bin/bashpositive_negative()
{
n=$1if [ $n-gt 0 ];thenecho"$n is a Positive Number"elif [ $n-lt 0 ];thenecho"$n is a Negative Number"elseecho"It is just Zero"fi
}
read -p "Enter Any number to test whether it is positive or negative: " n
positive_negative $n
Q12) Write a Function to Check whether the given Number is Prime or Not
#! /bin/bashprime_check()
{
n=$1if [ $n-le 1 ];thenecho"$n is not a PRIME number"else
is_prime="yes"for((i=2; i<n; i++))doif [ $((n % i))-eq 0 ];thenecho"$n is not a PRIME Number"
is_prime="no"breakfidoneif [ $is_prime="yes" ];thenecho"$n is a PRIME Number"fifi
}
read -p "Enter Any Number to test whether it is PRIME or not: " n
prime_check $n
Q13) Write a Function to Generate Prime Numbers Less Than or Equal to Given Number