OS(Operating System) Lab Class #1 Programs and Answer



 QUESTIONS:

(If you have any problem in running the code contact me: https://www.instagram.com/hemant_2.0.exe/)

1.) WAP to find number is even or odd.
2.) WAP to find sum of two numbers
3.) WAP to find highest of 3 Numbers.



ANSWERS:


1.)

echo enter the number
read count
if [ `expr $count % 2` -eq 0 ]
then
echo Even
else
echo Odd
fi


2.)

echo Enter 2 numbers
read n1 n2
sum=`expr $n1 + $n2`
echo Sum is $sum

3.)

echo Enter three number
read num1 num2 num3
if [ $num1 -gt $num2 -a $num1 -gt $num3 ]
then
echo $num1 is greatest
elif [ $num2 -gt $num1 -a $num2 -gt $num3 ]
then
echo $num2 is greatest
else
echo $num3 is greatest
fi



### SAVE THE FILE AS FILENAME.SH(odd.sh)
### RUN USING ./FILENAME.SH(./odd.sh)





WHAT IS SHELL SCRIPTING?


A shell script is a computer program designed to be run by the Unix/Linux shell which could be one of the following:

  • The Bourne Shell
  • The C Shell
  • The Korn Shell
  • The GNU Bourne-Again Shell

A shell is a command-line interpreter and typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Previous Post Next Post