Professional Documents
Culture Documents
Demonstrating: Who Command.: Rashmeen Kaur 02213401911
Demonstrating: Who Command.: Rashmeen Kaur 02213401911
Demonstrating: Who Command.: Rashmeen Kaur 02213401911
Demonstrating: Ls command.
Demonstrating: Ls P* command
Demonstrating Cd command
Demonstrating: Ls / command
Demonstrating: Vi editor
Demonstrating: Sh command
Demonstrating: Echo
Demonstrating: Clear
Demonstrating: Man
Demonstrating: Df
echo "Enter A Number:-" read n i=2 echo "Fibonacci Series is:-" a=0 b=1 echo $a echo $b while [ $i -lt $n ] do c=`expr $a + $b` echo $c a=$b b=$c i=`expr $i + 1` done
echo "Enter A Number:- " read num i=2 res=1 if [ $num -ge 2 ] then while [ $i -le $num ] do res=`expr $res \* $i` i=`expr $i + 1` done fi echo "Factorial of $num "is" $res"
echo Enter A Number:read number for i in 1 2 3 4 5 6 7 8 9 10 do echo "$number * $i = `expr $number \* $i`" done
echo "Enter A Number:-" read no echo "Enter its Power:-" read power counter=0 ans=1 while [ $power -ne $counter ] do ans=`expr $ans \* $no` counter=`expr $counter + 1` done echo "$no to the Power of $power is $ans"
echo "Enter A Number:- " read num i=2 while [ $i -lt $num ] do if [ `expr $num % $i` -eq 0 ] then echo "This is not a Prime Number" exit fi i=`expr $i + 1` done echo "This is a Prime Number"
echo "Enter A Number:-" 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 if [ $s -eq $t ] then echo "This is an Armstrong Number" else echo "This is not an Armstrong Number" fi
echo "Enter A Number:- " read n sd=0 rev="" on=$n while [ $n -gt 0 ] do sd=$(( $n % 10 )) # get Remainder n=$(( $n / 10 )) # get next digit rev=$( echo ${rev}${sd} ) done if [ $on -eq $rev ]; then echo "This is a Palindrome" else echo "This is not a Palindrome" fi
Program 8: WAP to find out the given year is a leap year or not.
echo "Enter A Year:- " read yy if [ $((yy % 4)) -ne 0 ] ; then : elif [ $((yy % 400)) -eq 0 ] ; then isleap="true" elif [ $((yy % 100)) -eq 0 ] ; then : else # it is a leap year isleap="true" fi if [ "$isleap" == "true" ]; then echo "This is a Leap Year" else echo "This is not a Leap Year" fi
echo "Enter the Radius:-" read r d=$(echo "scale=2;2 * $r"|bc) circumference=$(echo "scale=2;3.14 * $d"| bc) echo "Circumference of circle is $circumference"
echo Length of a rectangle read length echo Breadth of a rectangle read breadth echo Radius of a circle read radius area=echo $length \* $breadth | bc perimeter=echo 2 \* $length \* $breadth |bc echo Area of the rectangle : $area echo Perimeter of the rectangle : $perimeter