Maddy
Maddy
Program:
echo " A simple calculator " echo " enter two number " read a b echo "1.addition 2.subtraction 3.multiplication 4.division 5.exit" echo " enter the choice for operation " read op case $op in 1) c=`expr $a + $b `;; 2) c=`expr $a - $b `;; 3) c=`expr $a \* $b `;; 4) c=`expr $a / $b `;; 5) clear;; 6) exit;; esac echo $c
Output:
STRING CONCATINATION
Program:
echo "Enter the first string" read s1 echo "Enter the second string" read s2 echo "Concatenated string is:" $s1 $s2
output:
STRING COMPARISON
Program:
echo "Enter the first string" read s1 echo "Enter the second string" read s2 if [ $s1 == $s2 ] then echo "The string are equal" else echo "The string are not equal" fi
Output:
SUM OF N NUMBERS
Program:
echo " Enter the value" read n i=0 sum=0 while [ $i -lt $n ] do r=`expr $n % 10 ` n=`expr $n / 10 ` sum=`expr $sum + $r ` done echo $sum
Output:
ARMSTRONG NUMBER
Program:
echo "Enter the no." read n t=$n s=0 b=0 c=10 while [ $n -gt $b ] do r=`expr $n % $c` i=`expr $r \* $r \* $r` s=`expr $s + $i` n=`expr $n / $c` done echo $s if [ $s -eq $t ] then echo "Armstrong no." else echo "Not an armstrong no." fi
Output:
FIBONNACI SERIES 2
Program:
echo "Enter a number" read n a=-1 b=1 i=1 while [ $i -le $n ] do c=`expr $a + $b ` a=$b b=$c echo $c i=`expr $i + 1 ` done
Output:
FACTORIAL OF A NUMBER
Program:
echo "Enter the number" read no fact=1 i=1 while [ $i -le $no ] do fact=`expr $fact \* $i ` i=`expr $i + 1` done echo "the factorial of $no is $fact "
Output:
Output:
Output:
echo "Enter the number" read n i=0 sum=0 while [ $i -lt $n ] do echo "Enter the value" read n1 sum=`expr $sum + $n1 ` i=`expr $i + 1` done echo " sum : $sum "
Output:
AREA OF A CIRCLE
PROGRAM:
echo "Enter the radius of the circle:" read r a=$(((22/7)*$r*$r)) echo "AREA OF THE CIRCLE=$a"
Output:
echo "ENTER THE NUMBER :" read n r=`expr $n % 2` if [ $r -eq 0 ] then echo "THE GIVEN NUMBER IS EVEN" else echo "THE GIVEN NUMBER IS ODD" fi
Output:
PROGRAM:
echo " Basic salary " read Basic da=`expr $Basic \* 10 / 100` hra=`expr $Basic \* 20 / 100` gross=`expr $Basic + $da + $hra ` echo "gross salary = $gross"
Output:
PROGRAM:
echo "Enter the upper limit" read n i=2 while [ $i -lt $n ] do sum=`expr $sum + $i` i=`expr $i + 2` done echo "Sum is:$sum"
Output: