Professional Documents
Culture Documents
Os Lab File
Os Lab File
RECORD
BACHELOR OF TECHNOLOGY
Grade/Marks Obtained :
11
Experiment: 1
Date : 28.01.2022
SOLUTION:
echo "Enter two numbers"
read a
read b
echo "Before swapping"
echo "a=$a & b=$b"
c=$a
a=$b
b=$c
echo "After swapping"
echo "a=$a & b=$b"
OUTPUT:
RESULT:
The program for performing swapping of two numbers was compiled and executed successfully
in UNIX .
Experiment: 1
Date: 28.01.2022
SOLUTION:
OUTPUT:
RESULT :
The program for performing swapping of three numbers was compiled and executed successfully
in UNIX .
Experiment: 2
Date:28.01.2022
Aim: Write a program for finding the greatest between two numbers
SOLUTION:
echo "enter two numbers"
read a
read b
if [ $a -gt $b ]
then
echo " greatest number is : $a"
else
echo " greatest number is : $b"
fi
OUTPUT:
RESULT:
The program for was finding the greatest between two numbers was compiled and executed
successfully in UNIX .
Experiment: 2
Date:28.01.2022
Aim: Write a program for finding the greatest among three numbers
SOLUTION:
echo "Enter three numbers :"
read a
read b
read c
if [ $a -gt $b ] && [ $a -gt $c ]
then
echo "Greatest Number is $a"
elif [ $b -gt $a ] && [ $b -gt $c ]
then
echo "Greatest Number is $b"
else
echo "Greatest Number is $c"
fi
OUTPUT:
RESULT:
The program for was finding the greatest among three numbers was compiled and executed
successfully in UNIX .
Experiment: 3
Date-04.02.2022
Aim: Write a program to check whether the entered number is even or odd.
SOLUTION:
echo "Enter a number"
read a
if [ ` expr $a % 2 ` -eq 0 ]
then
echo "Number is even."
else
echo "Number is odd."
fi
OUTPUT:
RESULT:
The program to check whether the entered number is even or odd was compiled and executed
successfully in UNIX .
Experiment: 4
Date- 04.02.2022
Aim: Write a program tocheck entered number is positive, negative or zero .
SOLUTION:
echo "Enter the number"
read a
if [ $a -lt 0 ]
then
echo "Negative number"
elif [ $a -gt 0 ]
then
echo "Positive number"
else
echo "Number is zero"
fi
OUTPUT:
RESULT:
The program to check entered number is positive, negative or zero was compiled and executed
successfully in UNIX .
Experiment: 5
Date-04.02.2022
Aim:To write a menu driven program which has options today’s date,list of files whoami
and quit.
SOLUTION:
echo "MENUS"
echo "1.Todays date"
echo "2.List of files"
echo "3.Who am i"
echo "4.Quit"
echo "Enter your choice"
read a
case $a in
1)date;;
2)ls ;;
3)who am i ;;
4)exit ;;
esac
OUTPUT:
RESULT:
The program which has options today’s date,list of files ,whoami and quit was compiled and
executed successfully in UNIX .
Experiment: 6
Date-04.02.2022
Aim: To write a program in UNIX for performing various Arithmetic Operation using
Case Statement.
SOLUTION:
echo "Enter two numbers :"
read a
read b
echo "Chose :"
echo "1. Add"
echo "2.Subtract"
echo "3.Multiply"
echo "4.Divide"
echo "5.Exit"
read c
case $c in
1) echo "Sum = `expr $a + $b` " ;;
2) echo "Difference = `expr $a - $b` " ;;
3) echo "Product = `expr $a \* $b ` " ;;
4) echo " Quotient = `expr $a / $b ` " ;;
5) exit ;;
esac
OUTPUT:
RESULT:
The program for performing various Arithmetic Operation using Case Statement was compiled
and executed successfully in UNIX .
Experiment: 7
Date-04.02.2022
Aim:To WAP in UNIX to print n natural numbers.
SOLUTION:
echo "Enter the limit : "
read n
i=1
while [ $i -le $n ]
do
echo "$i"
i=`expr $i + 1`
done
OUTPUT:
RESULT:
The program to print n natural numbers was compiled and executed successfully in UNIX .
Experiment: 8
Date-04.02.2022
SOLUTION:
echo "Enter the limit"
read n
i=2
while [ $i -le $n ]
do
echo “$i”
i=`expr $i + 2`
done
OUTPUT:
RESULT:
The program to print n even natural numbers was compiled and executed successfully in UNIX .
Experiment: 9
Date-11.02.2022
Aim:To WAP in UNIX to print factorial of a number
SOLUTION:
echo "Enter a number"
read n
f=1
while [ $n -gt 1 ]
do
f=`expr $f \* $n`
n=`expr $n - 1`
done
echo "Factorial is : $f"
OUTPUT:
RESULT:
The program to print factorial of a number was compiled and executed successfully in UNIX.
Experiment: 10
Date-11.02.2022
Aim:To WAP in UNIX to print Fibonacci series
SOLUTION:
echo "Program to Find Fibonacci Series"
echo "How many number of terms to be generated ?"
read n
x=0
y=1
i=2
echo "Fibonacci Series up to $n terms :"
echo "$x"
echo "$y"
while [ $i -le $n ]
do
i=`expr $i + 1 `
z=`expr $x + $y `
echo "$z"
x=$y
y=$z
done
OUTPUT:
RESULT:
The program to print Fibonacci series was compiled and executed successfully in UNIX.