0% found this document useful (0 votes)
39 views16 pages

Os Lab File

The document contains a lab record for a student's Operating Systems course. It includes 10 programming assignments completed by the student between January 28th and February 11th involving writing programs in UNIX/Linux to perform tasks like swapping numbers, checking number properties, performing arithmetic, and calculating factorials and Fibonacci sequences. It documents the student's name, enrollment number, programs written, outputs, and results for each assignment.
Copyright
© © All Rights Reserved
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)
39 views16 pages

Os Lab File

The document contains a lab record for a student's Operating Systems course. It includes 10 programming assignments completed by the student between January 28th and February 11th involving writing programs in UNIX/Linux to perform tasks like swapping numbers, checking number properties, performing arithmetic, and calculating factorials and Fibonacci sequences. It documents the student's name, enrollment number, programs written, outputs, and results for each assignment.
Copyright
© © All Rights Reserved
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/ 16

LAB

RECORD
BACHELOR OF TECHNOLOGY

B.Tech.CSE - Semester (IV)

(Academic Session – 2021 -22)

Course Title : Operating System


Course Code : CSE202
Enrollment No. : A7605220007
Name of Student : RAKSHITA RAJAN SINGH
Date of Submission : //
Signature of Student :

Grade/Marks Obtained :

Faculty Name & Signature: Dr. Puneet Sharma

Department of Computer Science & Engineering


Amity School of Engineering & Technology
Amity University, Lucknow Campus
INDEX
S.NO. List of Programs Date Sign Remark
1 A. WAP in UNIX for swapping of two 28.01.2022
numbers.
WAP in UNIX for swapping of three numbers.
2 A. WAP in UNIX to print the greater of 28.01.2022
the two numbers.
B. WAP in UNIX to print the greatest of
the three numbers
3 Write a program to check whether the entered 04.02.2022
number is even or odd.
4 Write a program to check entered number is 04.02.2022
positive, negative or zero.
5 WAP a menu driven program which has 04.02.2022
options today’s date,list of files,whoami and
quit. Note that the program should display the
output as per the user’s choice.
6 WAP in UNIX for performing various 04.02.2022
Arithmetic Operation using Case Statement.
7 WAP in UNIX to print n natural numbers. 04.02.2022

8 WAP in UNIX to print sum of n even natural 04.02.2022


number.
9 WAP in UNIX to print factorial of a number. 11.02.2022

10 WAP in UNIX to print Fibonacci series. 11.02.2022

11
Experiment: 1
Date : 28.01.2022

Aim: To write a program for performing swapping of two numbers

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

Aim : Write a program for performing swapping of three numbers.

SOLUTION:

echo "Enter 3numbers"


read a
read b
read c
echo "Before swapping"
echo "a=$a b=$b c=$c"
t=$c
c=$a
a=$b
b=$t
echo "After swapping "
echo "a=$a b=$b c=$c"

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

Aim:To WAP in UNIX to print n even natural numbers.

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.

You might also like