Osy Practical Output
Osy Practical Output
Practical 2
Practical 3
Practical 4
5
Practical 6
Practical 7
Practical 8
Practical 10
Single decision :
echo "Enter percentage here :"
read grade
if [ $grade -ge 90 ] && [ $grade -le 100 ]
then
echo "Grade A"
fi
if [ $grade -ge 70 ] && [ $grade -lt 90 ]
then
echo "Grade B"
fi
if [ $grade -ge 50 ] && [ $grade -lt 70 ]
then
echo "Grade C"
fi
if [ $grade -ge 35 ] && [ $grade -lt 50 ]
then
echo "Grade D"
fi
if [ $grade -lt 35 ]
then
echo "FAIL"
fi
Double decision
echo "Enter percentage of Student : "
read grade
if [ $grade -gt 40 ]
then
echo "Pass"
else
echo "Fail"
fi
Multiple decision
echo "Enter percentage of Student : "
read grade
if [ $grade -ge 90 ]
then
echo "Grade A"
elif [ $grade -ge 80 ]
then
echo "Grade b"
elif [ $grade -ge 70 ]
then
echo "Grade c"
elif [ $grade -ge 60 ]
then
echo "Grade d"
elif [ $grade -ge 40 ]
then
echo "Grade e"
else
echo "Grade Fail"
fi
Nested if
read -p 'username :' username
if [ "$username" == "abc" ]
then
read -p 'password :' password
if [ "$password" == "pwd" ]
then
echo "Login Successfully"
else
echo "Wrong Password"
fi
else
echo "Wrong Username"
fi
Finding greatest number
echo "Enter number1 number : "
read n1
echo "Enter number2 number : "
read n2
echo "Enter number3 number : "
read n3
if [ $n1 -gt $n2 ] && [ $n1 -gt $n3 ]
then
echo "$n1 is Greater"
elif [ $n2 -gt $n3 ]
then
echo "$n2 is Greater"
else
echo "$n3 is Greater"
fi
Practical 11
Fibonacci series
read -p 'Enter no for fibonacci = ' no
x=0
y=1
no1=$no
while [ $no -gt 0 ]
do
z=$(( x + y ))
#echo $z
x=$y
y=$z
no=$(( no - 1 ))
done
echo "Fibonacci of $no1 is $y"
Print * pattern
Practical 12
Shell script to copy program one file to another
echo "Enter File name to copy \c"
read f1
echo "Enter file name \c"
read f2
if [ -f $f1 ]
then
cp $f1 $f2
else
echo "$f1 does not exist"
fi
Case statement
echo "enter file name"
read file
if [ -d "$file" ]
then
echo "it is directory"
else
echo "Enter your choice"
echo "1.copy file "
echo "2.rename file"
echo "3.remove"
read ch
case "$ch" in
"1") echo "Enter file name to be copied"
read cpfile
cp $file $cpfile
echo "File copied"
;;
"2") echo "enter name to rename "
read newname
mv $file $newname
echo "$file renamed as $newname"
;;
"3") rm $file
echo "removed "
;;
esac
fi
Practical 13
pwd
ls > f
exec < f
while read line
do
if [ -f $line ]
then
if [ -x $line ]
then
echo $line
fi
fi
done
pwd
ls > f
exec < f
while read line
do
if [ -f $line ]
then
if [ -r "$line" ] && [ -w "$line" ] && [ -x "$line" ]
then
echo $line has all the permissions
fi
fi
done
Practical 14
#include <stdio.h>
#include <conio.h>
int main() {
int n, bt[20], wt[20], tat[20], avwt = 0, avtat = 0, i, j;
printf("\nEnter Total Number of Processes (maximum 20): ");
scanf("%d", &n);
printf("\nEnter process burst times:\n");
for(i = 0; i < n; i++) {
printf("\nP[%d]: ", i + 1);
scanf("%d", &bt[i]);}
wt[0] = 0;
for(i = 1; i < n; i++) {
wt[i] = 0;
for(j = 0; j < i; j++)
wt[i] += bt[j];}
printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time:\n");
for(i = 0; i < n; i++) {
tat[i] = bt[i] + wt[i];
avwt += wt[i];
avtat += tat[i];
printf("\nP[%d]\t\t%d\t\t%d\t\t%d", i + 1, bt[i], wt[i], tat[i]);
}
avwt /= i;
avtat /= i;
printf("\n\nAverage Waiting Time: %d", avwt);
printf("\nAverage Turnaround Time: %d", avtat);
return 0;
}
Practical 15
#include <stdio.h>
int main() {
int i, j, n, a[50], frame[10], no, k, Flag, count = 0;
printf("\nENTER THE NUMBER OF PAGES:\n");
scanf("%d", &n);
printf("\nENTER THE PAGE NUMBERS:\n");
for(i = 0; i < n; i++)
scanf("%d", &a[i]);
printf("\nENTER THE NUMBER OF FRAMES:\n");
scanf("%d", &no);
for(i = 0; i < no; i++)
frame[i] = -1;
j = 0;
printf("\n\tReference String\tPage Frames\n");
for(i = 0; i < n; i++) {
printf("%d\t\t", a[i]);
Flag = 0
for(k = 0; k < no; k++) {
if(frame[k] == a[i]) {
Flag = 1;
break;
}
}
if (Flag == 0) {
frame[j] = a[i];
j = (j + 1) % no;
count++;
for(k = 0; k < no; k++)
printf("%d\t", frame[k]);
printf("Page Fault: %d\n", count);
} else {
for(k = 0; k < no; k++)
printf("%d\t", frame[k]);
printf("Page Hit\n");
}
}
printf("\nTotal Page Faults: %d\n", count);
return 0;
}
Practical 9
Create command