You are on page 1of 2

OS LAB Assignment-3 (CSE - 18)

# Q1. WASS to initialize two integer values and perform all the arithmetic operations.

Code:
a=5
b=6
echo "Two numbers are initialized as $a and $b."
c=`expr $a + $b`
d=`expr $a - $b`
e=`expr $a \* $b`
f=`expr $a / $b`
echo "Summation $c"
echo "Difference $d"
echo "Multiplication $e"
echo "Division $f"
~
Output:
Two numbers are initialized as 5 and 6.
Summation 11
Diffrence -1
Multiplication 30
Division 0

#Q2. WASS to input the amount in paisa and find out how many rupees and paise.

Code:
echo "Enter the amount in Paisa -> "
read a
b=`expr $a / 100`
c=`expr $a % 100`
echo "$a Paisas =$b Rupees and $c Paisas."

Output:
Enter the amount in Paisa ->
1234
1234 Paisas =12 Rupees and 34 Paisas.

#Q3. WASS to input the time in seconds and find out how many hours, minutes and
seconds.

Code:
echo "Enter the time in Seconds -> "
read t
h=`expr $t / 3600`
m=`expr $t / 60`
s=`expr $t % 3600`
echo "$t Seconds =$h Hours $m minutes $s Seconds."

Output:
Enter the time in Seconds ->
12345
12345 Seconds =3 Hours 205 minutes 1545 Seconds.
#Q4. WASS to input two distances(km and meter), find the sum of that two inputted
distance and print in kilometers and meters.

Code:
echo "Enter the first distance in km ->"
read a
echo "Enter the second diatance in m ->"
read b
c=`expr $a \* 1000`
d=`expr $c + $b`
e=`expr $d / 1000`
f=`expr $d % 1000`
echo "$a km + $b meters =$e km and $f meters"

Output:
Enter the first distance in km ->
50
Enter the second distance in m ->
12345
50 km + 12345 meters =62 km and 345 meters

#Q5. WASS to find the area of a circle, by inputting the values of the radius.

Code:
echo "Enter the radius of a circle ->"
read a
b=`echo 3.14 \* $a \* $a | bc`
echo "The area of the circle =$b".

Output:
Enter the radius of a circle ->
5
The area of the circle =78.50

#Q6. WASS to find out the sum of two complex numbers.

Code:
echo "Enter the complex number in (real + imaginary*i) format."
echo "Enter first complex number ->"
read a b
echo "Enter the second complex number"
read c d
e=`echo $a + $c | bc`
f=`echo $b + $d | bc`
echo "Addition of two complex number =$e + $f*i"

Output:
Enter the complex number in (real + imaginary*i) format.
Enter first complex number ->
23
Enter the second complex number
45
Addition of two complex number =6 + 8*i

You might also like