0% found this document useful (0 votes)
24 views2 pages

Rem $N: "Enter Numnber: "

This script prompts the user to enter a number and determines if it is even or odd. It then prompts the user to enter three numbers and determines the greatest number or if they are equal. It displays the result.

Uploaded by

dipali18
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Rem $N: "Enter Numnber: "

This script prompts the user to enter a number and determines if it is even or odd. It then prompts the user to enter three numbers and determines the greatest number or if they are equal. It displays the result.

Uploaded by

dipali18
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

echo -n "Enter numnber : " read n rem=$(( $n % 2 )) if [ $rem -eq 0 ] then echo "$n is even number" else echo

"$n is odd number" fi

echo -n "Please enter three numbers (separate number by space) : " read a b c # compare a with b and c. Note -a is logical and operator if [ $a -gt $b -a $a -gt $c ] then big=$a elif then big=$b elif then big=$c elif [ $a -eq $b -a $a -eq $c -a $b -eq $c -a $c -eq $b ] # see if all of them are equal or not then big="All three numbers are same (equal)" else # something must be wrong if we are here, like one of number is character such as 'A' big="Can not guess greaters of three numbers" fi # display result [ $c -gt $a -a $c -gt $b ] # compare c with a and b [ $b -gt $a -a $b -gt $c ] # compare b with a and c

echo "Result : $big"

Answer:
Improve

i=2 rem=1 echo "Enter a number" read num if [ $num -lt 2 ] then echo "$num is not prime" exit 0 fi while [ $i -le `expr $num / 2` -a $rem -ne 0 ] do rem=`expr $num % $i` i=`expr $i + 1` done if [ $rem -ne 0 ] then echo "$num is prime" else echo "$num is not prime" fi

You might also like