Skip to main content

Command Palette

Search for a command to run...

Advance Operating System Practical

Updated
•6 min read•View as Markdown
Advance Operating System Practical

PRACTICAL 1

  1. Write the bash shell script to perform an operation addition , subtraction, multiplication, division, modulus, exponent of two numbers.

Code: -

echo "enter first number "
read num1
echo "enter the second number"
read num2

sum=$((num1+num2));
sub=$((num1-num2));
mult=$((num1*num2));
divide=$((num1/num2));
module=$((num1%num2));
expo=$((num1**num2));
echo "sum is: $sum"
echo "sub is: $sub"
echo "mult is: $mult"
echo "divide is: $divide"
echo "module is: $module"
echo "expo is: $expo"

Output:

Enter the first number :15

Enter the second number :12

Addition of two number is :27

Subtraction of two number is :3

Multiplication of two number is :180

Division of two number is :1

Modulus of two number is :3

Exponent of two number is :129746337890625


  1. Write the bash shell script to calculate the final velocity v of an object if initial velocity is u, acceleration a and time t.

Code: -

echo "Enter the initial velocity: ";

read "u"

echo "Enter the Acceleration: ";

read "a"

echo "Enter the time: ";

read "t"

velocity=$((u+a*t));

echo "final velocity (v) is: $velocity" 

Output:-

Enter the initial velocity:12

Enter the Acceleration:12

Enter the time:10

final velocity (v) is: 132

  1. Write the bash shell script to enter the value of principal value, rate of interest and time period and calculate the simple interest.

Code:-

echo "Enter the principal value: ";

read "p"

echo "Enter the rate of interest: ";

read "r"

echo "Enter the time period: ";

read "t"

SimInt=$((p*r*t/100));

echo "The simple interest is: $SimInt"

Output:-

Enter the principal value:13

Enter the rate of interest:45

Enter the time period:1

The simple interest is: 5

  1. Write a bash shell script to change temperature in Celsius into Fahrenheit.

Code:-

echo "Enter temperature in Degree Celsius: ";

read "TempCelsius"

Fahrenheit=$((TempCelsius*9/5+32));

echo "The temperature in Fahrenheit is: $Fahrenheit"

Output:-

Enter temperature in Degree Celsius:10

The temperature in Fahrenheit is: 50

  1. Write the bash shell script to calculate the CSA of cylinder and volume of cylinder.

Code:-

echo "enter the radius,height";
read r;
read h;

ar=$((2*22/7*r*h))
echo "curved surface area of cylinder is: $ar";


vol=$((22/7*r*r*h))
echo "volume of cylinder is: $vol";

Output:-

enter the radius of cylinder is:10

enter the height of cylinder is:15

CSA of cylinder is:942

Volume of cylinder is:4714


  1. Write the bash shell script to convert meter into centimeter, kilometer, decameter, millimeter.

Code:-

echo "enter the num in meter";
read m;

cm=$((m/100));
echo "meter convert into cm is: $cm";

km=$((m/1000));
echo "meter convert into cm is: $km";

mm=$((m*100));
echo "meter convert into mm is: $mm";

dm=$((m/10));
echo "meter convert into deca meter is: $dm";

Output:-

enter the number in m :5

convert m into cm:500

convert m into km:0

convert m into dm:50

convert m into mm :5000


  1. Write the bash shell script to convert rupee to paise and dollar into rupee.

Code: -

echo "enter the num in rupee";
read rs;

pa=$((rs*100));
echo "paise :$pa"

dol=$((rs/80));
echo "dollor: $dol";

Output:-

Enter amount in rupee:1

convert rupee into paisa100

Enter amount in dollar:5

convert dollar into rupee :400


  1. Write a bash shell script to calculate the area of Circle, Volume of sphere, Curved Surface area of cone.

Code:-

area of curved surface and volume of cylinder

echo "enter the radius,height";
read r;
read h;

ar=$((2*22/7*r*h))
echo "curved surface area of cylinder is: $ar";

vol=$((22/7*r*r*h))
echo "volume of cylinder is: $vol";

v=$((4/3*22/7*r*r*r));

echo "volume of sphere is: $v"

Output:-

Enter radius of circle:12

area of circle is:432

Enter radius:14

volume of sphere is:10976

Enter radius of cone:12

Enter slant height of cone:4

CSA of cone is:150


PRACTICAL-2

Q1- Write a bash shell script to check whether the person is eligible to vote or not.

CODE:-

echo "enter the age of voter"
read n;

if [ $n -gt 18 ]; then
    echo "eligible"
elif [ $n -lt 18 ]; then
    echo "not eligible"
else
    echo "you can apply"
fi

OUTPUT: -

Enter the Age of voter:- 21

You are eligible to vote


Q2- Write a bash shell script to find the greatest three number

CODE: -

echo "enter the first number"
read num1;
echo "enter the second number"
read num2;
echo "enter the third number"
read num3;

if [ $num1 -gt $num2 ]; then
    echo "num 1 is grater"
elif [ $num2 -gt $num3 ]; then
    echo "num2 is greater "
else
    echo "number 3 is greater"
fi

OUTPUT :-

Enter any two number:-

34

55

Second number is greater than first one


Q3- Write a bash shell script to find the greatest number among any three numbers.

CODE: -

echo "enter the first number"
read num1;
echo "enter the second number"
read num2;


if [ $num1 -gt $num2 ]; then
    echo "num 1 is grater"
else 
    echo "num 2 is greater "

fi

OUTPUT: -

Enter any three number:-

33 76 88

Third number is greater


Q4- Write a bash shell script to check whether the given year is leap year or not.

CODE: -

echo   "enter the  year";
read year;
if [ $((year%4)) -eq 0 ];then
echo "year is leap year";
else
echo "number is not a leap year";
fi

OUTPUT: -

Enter the year:- 2004

It is a leap year


Q5- Write a bash shell script to check whether the given number is even or odd

CODE: -

echo "enter the number"
read num;
if [ $((num%2)) -eq 0 ]; then
echo "number is even"
else
echo "number is odd"
fi

OUTPUT: -

Enter the Number:- 15

It is a odd number


Q6- Write a bash shell script to check whether the given number is positive integer or negative

CODE:-

echo   "enter the first number";
read num1;
if [ $num1 -gt 0 ];then
echo "number is positive"
else
echo "number is negative"
fi

OUTPUT: -

Enter the Number:- 45

It is positive number


PRACTICAL-3

Q1- Write a C program to simulate the FCFS Scheduling algorithm

CODE: -

#include <stdio.h>

int main() {
    int n;
    int bt[10];
    int wt[10];
    int tat[10];
    int awt = 0;
    int atat = 0;
    printf("Enter the number of process :-");
    scanf("%d",&n);
    printf("Enter the burst time for each process:-");
    for(int i=0;i<n;i++){
        scanf("%d",&bt[i]);
    }
    for(int i =0;i<n;i++){
      wt[i]=bt[i-1] + wt[i-1];  
      awt = awt+wt[i];
    }
    for(int i =0;i<n;i++){
      tat[i]=bt[i] + wt[i];  
      atat = atat+tat[i];
    }
    printf("Process  Wating time turnaroud time \n");
    for(int i=0;i<n;i++){
       printf("%d        %d     %d ",i,wt[i],tat[i]);
       printf("\n");
    }
    printf("Average Wating time is %d milisec  \nAverage turnaroud time %d milisec ",awt/n,atat/n);
    return 0;
}


OUTPUT :-

Enter the number of process: -  4
Enter the burst time for each process:-  4 5 7 1
Process | Burst time | Waiting time | turnaround time 
1            |         4           |          0             |      4 
2            |         5           |          4             |      9 
3            |         7           |          9             |      16 
4            |         1           |         16            |      17 
Average waiting time is 7.00 Millisecond  
Average turnaround time is 11.00 Millisecond