OS file revanth reddy
OS file revanth reddy
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY
LAB FILE
Page 1
MANAV RACHNA UNIVERSITY
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY
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:
Output:
Page 4
4. To enter a character and determine whether it is vowel or not.
Code:
Output:
Page 5
Output:
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:
Code:
Output:
Page 11
Lab: 01
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
Page 12
(v) Current Date: Day Abbreviation , Month Abbreviation along with year
Code: date +"%a, %b %Y"
Page 13
Lab: 02
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
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
8. Create files myfile and yourfile under Present Working Directory and display them.
Code: touch myfile yourfile
ls -l myfile yourfile
Page 14
11. Copy myfile file to emp.
Code: cp 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