0% found this document useful (0 votes)
3 views19 pages

Commands and Programs by Rashmeen Kaur

The document demonstrates various Linux commands like who, date, ls, pwd, mkdir, cd, vi editor, man, df, and programs to calculate Fibonacci series, factorial, multiplication table, power of a number, prime number check, Armstrong number check, palindrome check, leap year check, circle circumference, and rectangle area and perimeter. It provides the output of running each command and program for demonstration purposes.
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)
3 views19 pages

Commands and Programs by Rashmeen Kaur

The document demonstrates various Linux commands like who, date, ls, pwd, mkdir, cd, vi editor, man, df, and programs to calculate Fibonacci series, factorial, multiplication table, power of a number, prime number check, Armstrong number check, palindrome check, leap year check, circle circumference, and rectangle area and perimeter. It provides the output of running each command and program for demonstration purposes.
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

Demonstrating: Who command.

Demonstrating: Who m I command.

Demonstrating: Tput clear command.

RASHMEEN KAUR 02213401911

Demonstrating: Date command.

Demonstrating: Tty command.

Demonstrating: Cal command.

Demonstrating: Date +%h command.


RASHMEEN KAUR 02213401911

Demonstrating: Date +% m command.

Demonstrating: Ls command.

Demonstrating: Change mode numeric command.

RASHMEEN KAUR 02213401911

Demonstrating: Change mode sumbolic command.

Demonstrating: Ls P* command

Demonstrating: Pwd to present working directory


RASHMEEN KAUR 02213401911

Demonstrating: Mkdir command

Demonstrating Cd command

RASHMEEN KAUR 02213401911

Demonstrating : Creating the directories and changing directories

Demonstrating: Ls / command

Demonstrating: Vi editor

RASHMEEN KAUR 02213401911

Demonstrating: Sh command

RASHMEEN KAUR 02213401911

Demonstrating: Dir command

Demonstrating: Echo

Demonstrating: Clear

RASHMEEN KAUR 02213401911

Demonstrating: Man

Demonstrating: Df

RASHMEEN KAUR 02213401911

Program 1: WAP to find out Fibonacci Series of a number

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

RASHMEEN KAUR 02213401911

Program 2: WAP to find out Factorial of a number.

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"

RASHMEEN KAUR 02213401911

Program 3: WAP to display table of a number.

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

RASHMEEN KAUR 02213401911

Program 4: WAP to calculate power of a number.

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"

RASHMEEN KAUR 02213401911

Program 5: WAP to check whether a number is prime or not.

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"

RASHMEEN KAUR 02213401911

Program 6: WAP to check whether a number is Armstrong or not.

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

RASHMEEN KAUR 02213401911

Program 7: WAP to check whether a number is palindrome or not.

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

RASHMEEN KAUR 02213401911

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

RASHMEEN KAUR 02213401911

Program 9: WAP to find out the Radius of a Circle.

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"

RASHMEEN KAUR 02213401911

Program 10: WAP to display Area & perimeter of Rectangle.

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

RASHMEEN KAUR 02213401911

You might also like