0% found this document useful (0 votes)
16 views

Lab Assignment-3 - DOS

Uploaded by

gudulabanshika
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Lab Assignment-3 - DOS

Uploaded by

gudulabanshika
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Laboratory Assignments 3

Subject: Design Principles of Operating Systems


Subject code: CSE 3249

Assignment 3: Shell Programming using user defined variables, arithmetic


operators, conditional statements.

Objective of this Assignment:


 To learn the proper use of user defined variables and arithmetic operators in shell
programming.
 To write shell script producing solution to decision making problems.

1. Write a shell script iaop to perform integer arithmetic on two numbers, where the value
of the two numbers will be given during runtime.

2. Write a shell script faop to perform floating point arithmetic on two numbers, where the
value of the two numbers will be given during runtime.

3. Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of
basic salary, and house rent allowance is 20% of basic salary. Write a program to
calculate his gross salary.

4. If a five digit number is input given through the keyboard during runtime, write a
program to calculate the sum of its digits.

5. If cost price and selling price of an item is input through the keyboard, write a program to
determine whether the seller has made profit or incurred loss. Also determine how much
profit was made or loss incurred.

6. Write a shell script which receives any year from the keyboard and determines, whether
the year is a leap year or not. If no argument is supplied the current year should be
assumed.

7. Write a shell script allow that will display a message to enter internal mark and
percentage in attendance, if the entered mark is greater than equal to 20 and entered
percentage in attendance is greater that equal to 75 then display the message Allowed for
Semester otherwise display the message Not allowed.

8. Write a shell script small3 that will compare three numbers passed as command line
arguments and display the smallest one.

9. Write a shell script check_char which will display one message to enter a character and
according to the character entered it will display appropriate message from the following
options:
 You entered a lower case alphabet
 You entered an upper case alphabet.
 You have entered a digit.
 You have entered a special symbol.
 You have entered more than one character.

10. Write a shell script class_time which will display one message to enter a day and
according to the day entered it will display the DOS class time along with the room
information or the message “No class on day_name” or “Holiday” for Sunday.

11. Write a shell script filechk that will take two file names as command line arguments, and
check whether the content of two files are same or not . If contents of two files are same,
then it will display the message: Files filename1 and filename2 have same content.
then delete the second file
and display the message: So filename2 is deleted.
Otherwise display the message: Files filename1 and filename2 have different content.

12. Write a shell script calculator that will take three command line arguments, where the
first argument will specify the first operand, second argument will specify the operator
and the third argument will specify the second operand and display the output of the
arithmetic operation specified in the following format: op1 operator op2 = result .

If the arguments will be passed in any other sequence, it will display the message:

“Invalid input “

Enter input in following format: op1 operator op2

The symbols to be used for different operators are as follows:

Addition: + Subtraction: -

Multiplication: x Division: /

Modulo: % Exponent: ^

You might also like