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

OS file revanth reddy

The document is a lab file for the Operating Systems Lab (CSH206B-P) at Manav Rachna University, detailing various programming assignments and Unix commands. It includes objectives, learning outcomes, and sample code for tasks related to C programming and Unix file handling. The lab assignments cover topics such as decision control, iterative statements, arrays, and basic Unix commands for file management.

Uploaded by

phr8519834
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)
7 views

OS file revanth reddy

The document is a lab file for the Operating Systems Lab (CSH206B-P) at Manav Rachna University, detailing various programming assignments and Unix commands. It includes objectives, learning outcomes, and sample code for tasks related to C programming and Unix file handling. The lab assignments cover topics such as decision control, iterative statements, arrays, and basic Unix commands for file management.

Uploaded by

phr8519834
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/ 15

MANAV RACHNA UNIVERSITY

SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY

LAB FILE

OPERATING SYSTEMS LAB (CSH206B-P)

Submitted to: Submitted by:


Dr. Awwab Mohammad roll no :
2K23CSUN01140
Assistant Professor name :C.REVANTH
REDDY
MRU-DoCST B.tech CSE-4C

Page 1
MANAV RACHNA UNIVERSITY
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY

S. No. Lab Assignment Topic Date Page No. Faculty Remarks

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

Page 2
Lab-0
To revisit and implement C Programming Concepts
Laboratory Objective: To revisit and implement C Programming Concepts
Learning Outcome: To gain familiarity with the concepts of C.
Course Outcome: CO1
Blooms Taxonomy: BT1, BT2, BT3, BT4
Write programs using the C/C++ Language

Basics
1. To swap two numbers without using a temporary variable.
Code:

Output:

2. To calculate the bill amount for an item given the quantity sold, rate, discount and tax.
Code:

Page 3
Output:

Based on Decision Control


3. Program to enter any character. If the entered character is in lower case then convert it into upper case
and if it is lower case then convert it into upper case.
Code:

Output:

Page 4
4. To enter a character and determine whether it is vowel or not.
Code:

Output:

Based on Switch Case:


5. Program to display a menu that offers five options: Read three numbers, calculate total, average,
display the smallest and largest value.
Code:

Page 5
Output:

Based on Iterative Statements


6. To classify a number as prime or composite.

Code:

Page 6
Output:

Based on Functions
7. To find the Fibonacci using recursive function.

Code:

Output:

Page 7
Based on Arrays
8. To insert a number at a given location in an array.
Code:

Output:

9. In a class there are 10 students. Each student is supposed to appear in three tests. Write a program
using 2D array to print
a. The marks obtained by each student in different subjects.
b. Sort the average obtained by each student.
Code:

Page 8
Output:

Page 9
10. Accept any two strings from the user. Display whether both the strings are equal or not. (do not use
standard functions).

Code:

Output:

Based on Structures
11. Write a program to accept a list of 10 integers in an array, pass the starting address of array in sum
function, calculate the sum of the array elements in the function and return the sum calculated in the
main function.

Code:

Page 10
Output:

Based on Command Line Arguments


12. Program to add two numbers using Command Line Arguments.

Code:

Output:

Page 11
Lab: 01

Unix General Utilities Commands


Laboratory Objective: To implement Basic commands of Unix and Handling Ordinary Files
Course Outcome CO1: To understand the basics Unix commands
Blooms Taxonomy Level: BT1-BT3

1. Obtain the following results


(i) To print the name of operating system
Code: uname

(ii) To print the version of the operating system


Code: uname -r

(iii) To print the name of the machine


Code: uname -m

(iv)To print the login name


Code: whoami

(v) To print the host name


Code: hostname

2. Write commands to:


(i) Find out the users who are currently logged in and find the particular user too.

Code: who
who | grep "username"

(ii) Find out the detailed list of users who are currently logged in with column headings in the
output.
Code: who -H

3. Display the calendar for


(i) Jan 2000
Code: cal 01 2000

(ii) Feb 1999


Code: cal 02 1999

(iii) 9th month of the year 7 A.D


Code: cal 09 0007

(iv) For the current month


Code: cal

Page 12
(v) Current Date: Day Abbreviation , Month Abbreviation along with year
Code: date +"%a, %b %Y"

4. Display the time in 12-Hour and 24 Hour Notations.


Code: date +"%r"
date +"%T"

5. Display the Current Date and Current Time.


Code: date

6. Display the message “Manav Rachna University” on screen.


Code: echo "Manav Rachna University"

7. Write a command to count the output of “who” command.


Code: who | wc -l

8. Write a command to know your terminal name.


Code: tty

9. Obtain the following results:


(i) Calculate result of 14*14.
Code: echo $((14 * 14))

(ii) Calculate result of 2 to the power 32.


Code: echo $((2 ** 32))

(iii) Calculate result of 12/5.


Code: echo "scale=2; 12/5" | bc

(iv) Calculate decimal equivalent of 1100101001.


Code: echo $((2#1100101001))

(v) Calculate binary equivalent of 151.


Code: echo "obase=2; 151" | bc

Page 13
Lab: 02

Unix File Handling Commands

Laboratory Objective: To implement Basic commands of Unix and Handling Ordinary Files
Course Outcome CO1: To understand the basics Unix commands
Blooms Taxonomy Level: BT1-BT3

File Handling
1. Create a directory SAMPLE under your home directory.
Code: mkdir ~/SAMPLE

2. Create a sub-directory by name TRIAL under SAMPLE.


Code: mkdir ~/SAMPLE/TRIAL

3. Change from home directory to TRIAL by using absolute and relative pathname.
Code: # Absolute Pathname
cd ~/SAMPLE/TRIAL
# Relative Pathname (assuming you're in home directory)
cd SAMPLE/TRIAL

4. Remove directory TRIAL.


Code: rmdir ~/SAMPLE/TRIAL

5. Create a directory TEST using absolute pathname.


Code: mkdir ~/TEST

6. Using a single command change from current directory to home directory.


Code: cd ~

7. Remove a directory using absolute pathname.


Code: rmdir ~/TEST

8. Create files myfile and yourfile under Present Working Directory and display them.
Code: touch myfile yourfile
ls -l myfile yourfile

9. Append more lines in the myfile and yourfile files.


Code: echo "This is a new line" >> myfile
echo "Another line" >> yourfile

10. How will you create a hidden file


Code: touch .hiddenfile

Page 14
11. Copy myfile file to emp.
Code: cp myfile emp

12. Write the command to create alias name for a file.


Code: alias myalias='cat myfile'

13. Move yourfile file to dept.


Code: mv yourfile dept

14. Copy emp file and dept file to TRIAL directory


Code: cp emp dept ~/SAMPLE/TRIAL

15. Compare myfile file and emp file.


Code: diff myfile emp

16. Append two more lines in emp file existing in TRIAL directory.
Code: echo "Line 1 added" >> ~/SAMPLE/TRIAL/emp
echo "Line 2 added" >> ~/SAMPLE/TRIAL/emp

17. Find difference between employee file with emp file in TRIAL directory.
Code: diff employee ~/SAMPLE/TRIAL/emp

Page 15

You might also like