0% found this document useful (0 votes)
26 views36 pages

Linux Record 2023 24

Uploaded by

Narenkumar. N
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)
26 views36 pages

Linux Record 2023 24

Uploaded by

Narenkumar. N
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/ 36

RECORD NOTEBOOK

Linux Operating System – (HBCA21A12)

2024-2025(ODD

SEMESTER)

DEPARTMENT

OF

COMPUTER
APPLICATION

NAME :
REGISTER NO :
COURSE : BCA AI & DS
YEAR/SEM/SEC :
BONAFIDE CERTIFICATE

Register No:

Name of Lab: Linux Operating System –


(HBCA21A12) Department: COMPUTER
APPLICATION

Certified that this is a Bonafide Record of work done by _ of BCA


III year in Linux Operating System LABORATORY during the V semester in the year
2024-2025.

Signature of Lab-in-Charge Signature of Head of Dept

Submitted for the Practical Examination held on _

Internal Examiner External Examiner


List of Experiments

DATE OF PAGE
TOPIC SIGNATURE
SL.NO EXPERIMENT NO

1. 25/07/2024 PRIME TEST.

2. 30/07/2024 PALINDROME TEST.

3. 01/08/2024 FIBONACCI SERIES


GENERATION.

4. 06/08/2024 ARMSTRONG NO TEST.

5. 08/08/2024 SOLVING QUADRATIC


EQUATION with MACROS

6. 13/08/2024 MENU DRIVEN SHELL SCRIPT -


SORT WITH VARIOUS OPTIONS
with THE APPLICATION OF
PROCEDURES

7. 13/08/2024 USAGE OF CASE STRUCTURES.

8. 22/08/2024 PROCESS SCHEDULING:FCFS

9. 31/08/2024 PROCESS SCHEDULING:ROUND


ROBIN

10. 09/09/2024 USING PIPES TO CALCULATE


NCR with THE APPLICATION OF
FUNCTIONS
Experiment Date : 25/07/2024 Page No…

Exercise Title : 1.PRIME TEST.

Aim:

Algorithm:
Program:

echo "Enter a number: "


read num
i=2
f=0
while [ $i -le `expr $num / 2` ]
do
if [ `expr $num % $i` -eq 0 ]
then
f=1
fi
i=`expr $i + 1`
done
if [ $f -eq 1 ]
then
echo "The number is composite"
else
echo "The number is Prime"
fi
Output:

Enter the
number13
The Number is Prime

Enter the
Number10
The Number is Composite

Result:
Experiment Date : 30/07/2024 Page No…

Exercise Title : 2.PALINDROME TEST.

Aim:

Algorithm:
Program:

echo "Enter a string to be entered:"


read str
echo
len=`echo $str | wc -c`
len=`expr $len - 1`
i=1
j=`expr $len / 2`
while test $i -le $j
do
k=`echo $str | cut -c $i`
l=`echo $str | cut -c $len`
if test $k != $l
then
echo "String is not palindrome"
exit
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
echo "String is palindrome"
Output:

Enter a String
Madam
Palidrome String

Enter a String
Daddy
Not a palindrome string

Result:
Experiment Date : 01/08/2024 Page No…

Exercise Title : 3.FIBONACCI SERIES GENERATION.

Aim:

Algorithm:
Program:

echo "How many number of terms to be generated ?"


read n
x=0
y=1
i=2
echo "Fibonacci Series up to $n terms :"
echo "$x"
echo "$y"
while [ $i -lt $n ]
do
i=`expr $i + 1 `
z=`expr $x + $y `
echo "$z"
x=$y
y=$z
done
Output:

Enter how many number of terms to be generated


5
Generating and Printing the fibonnaci series
0
1
1
2
3

Result:
Experiment Date : 06/08/2024 Page No…

Exercise Title : 4.ARMSTRONG NO TEST.

Aim:

Algorithm:
Program:

echo -n "Enter the number: "


read Number Length=$
{#Number} Sum=0
OldNumber=$Number
while [ $Number -ne 0 ]
do
Rem=$((Number%10)) Number=$
((Number/10)) Power=$(echo "$Rem ^
$Length" | bc ) Sum=$((Sum+$Power))
done
if [ $Sum -eq $OldNumber ]
then
echo "$OldNumber is an Armstrong number"
else
echo "$OldNumber is not an Armstrong number"
fi
numbers
Output:

Enter the Number


153
153 is an Armstrong number

Enter the Number


34567
34567 is not an Armstrong Number

Result:
Experiment Date : 08/08/2024 Page No…

Exercise Title : 5.SOLVING QUADRATIC EQUATION with MACROS.

Aim:

Algorithm:
Program:

#!/bin/bash
#for finding the value of x in "ax^2 + bx + c = 0"

echo -e "\e[1;34ma\e[1;31mx^2 \e[0m+ \e[1;34mb\e[1;31mx\e[0m + \e[1;34mc\e[0m = 0"


read -p "a=" a
read -p "b=" b
read -p "c=" c

#finding value of x using quadratic formula


x1=$(echo "scale=2; ((-1*$b) + (sqrt(($b*$b)-(4*$a*$c))))/(2*$a)" | bc 2> /dev/null) x2=$
(echo "scale=2; ((-1*$b) - (sqrt(($b*$b)-(4*$a*$c))))/(2*$a)" | bc 2> /dev/null)

#in case the value of x cannot be found


if [[ $x1 == $null && $x2 == $null ]];then
echo -e "\e[1;31mvalue of x cannot be found!!\e[0m"
else
echo -e "\e[1;31mx\e[0m=$x1, $x2"
fi
Output:

ax^2+bx+c=0
a=8
b=8
c=1
X=-.14,-.85

Result:
Experiment Date : 13/08/2024 Page No…

Exercise Title : 6.MENU DRIVEN SHELL SCRIPT - SORT WITH VARIOUS OPTIONS
with APPLICATIONS OF PROCEDURES.

Aim:

Algorithm:
Program:

#bin/bash/sh
ch=1

while test $ch -le 4


do
echo "1.Ascending order"
echo "2.Descending order"
echo "3.exit"
echo "Enter your choice:"
read ch

case $ch in

1)awk 'BEGIN {
printf "\nEnter the no of data:"
getline n
printf "\nEnter the element for sorting in Ascending:\n"
for(i=0;i<n;i++)
{
getline s[i]
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(s[i]>s[j])
{
t=s[i]
s[i]=s[j]
s[j]=t
}
}
}
printf "\nAscending order is....\n"
for(i=0;i<n;i++)
printf("%d\n",s[i]);
}';;

2) awk 'BEGIN {
printf "\nEnter the no of data:"
getline n
printf "\nEnter the elements for sorting in Descending:\n" for(i=0;i<n;i+
+)
{
getline s[i]
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(s[i]<s[j])
{
t=s[i]
s[i]=s[j]
s[j]=t
} } }
printf "\nDescending order is.....\n"
for(i=0;i<n;i++)
printf "%d\n",s[i]
}';;

3) exit;;
esac
done
Output:
1.Ascending Order
2.Desending Order
3.Exit
Enter your choice: 1
Enter the no of data: 5
Enter the element for sorting in Ascending:
33
67
89
23
75
Ascending Order is....
23
33
67
75
89
1.Ascending Order
2.Descending Oder
3.Exit
Enter your choice:2
Enter the no of data: 3
Enter the element for sorting in Descending:
86
46
69
Descending order is.....
86
69
46

Result:
Experiment Date : 13/08/2024 Page No…

Exercise Title : 7.USAGE OF CASE STRUCTURES.

Aim:

Algorithm:
Program:

#!/bin/bash
echo -n "Enter Number between 0 and 9: "
read n
case $n in
0) echo 'You typed 0.';;
1|9) echo "$n is a perfect square.";;
3|5|7) echo "$n is a prime number.";;
4) echo "$n is a perfect square.
$n is an even number";; 2|6|
8) echo "$n is an even number.";;
*) echo 'Only single-digit numbers are allowed.';;
esac
Output:
Enter a Number between 0 and 9:
55 is a prime number.

Result:
Experiment Date : 22/08/2024 Page No…

Exercise Title : 8.PROCESS SCHEDULING: FIRST COME FIRST SERVED (FCFS)

Aim:

Algorithm:
Program:
#include<stdio.h>
main()
{
int n,a[10],b[10],t[10],w[10],g[10],i,m;
float att=0,awt=0;

for(i=0;i<0;i++)
{ a[i]=0;b[i]=0;w[i]=0;g[i]=
0;
}
printf(“Enter the number of processes:”);
scanf(“%d”,&n);
printf(“Enter the burst time:”);
for(i=0;i<n;i++)
scanf(“%d”,&b[i]);
printf(“Enter the arrival time:”);

for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
g[0]=0;

for(i=0;i<10;i++)
{
w[i]=g[i]-a[i];
t[i]=g[i+1]-a[i];
awt=awt+w[i]
att=att+t[i];
}
awt=awt/n;
att=att/n;
printf(“\n\t Process\t Waiting time \t Turnaround time\n”);

for(i=0;i<n;i++)
{
printf(“\t %d\t\t %d\t\\t %d\n”I,w[i],t[i]);
}
printf(“\n The average waiting time is %t \n”,awt);
printf(“The average turnaround time is %f\n”,att);
OUTPUT:

[examuser35@localhost Jebastin]$ cc fcfs.c


[examuser35@localhost Jebastin]$ ./a.out
Enter the number of processes:3
Enter the burst time:1
2
3
Enter the arrival time:0
1
2

Process Waiting time Turnaround time


1
1 3 2
2 6 4

The average waiting time is 3.3333


The average turnaround time is 2.333

Result:
Experiment Date : 31/08/2024 Page No…
Exercise Title : 9.PROCESS SCHEDULING: ROUND ROBIN
Aim:

Algorithm:
Program-:
#include<stdio.h>
int ttime,i,j,temp;

int main(void)
{
int pname[10],btime[10],pname2[10],btime2[10];
int n,x,z;

printf("enter the no of process");


scanf("%d",&n);

printf("Enter the process name & burst time for the process\n");
for(i=0;i<n;i++)
{
printf("Enter the process name");
scanf("%d",&pname2[i]);
printf("Enter the burst time for the process %d");
scanf("%d",&btime2[i]);
}

printf("PROCESS NAME\t\tBURST TIME\n");


for(i=0;i<n;i++)
printf("%d\t\t\t%d\n",pname2[i],btime[i]);
z=1;
while(z==1)
{
ttime=0;
for(i=0;i<n;i++)
{
pname[i]=pname2[i];
btime[i]=btime2[i];
}

printf("\npress 1.roundrobin \n2.exit");


scanf("%d",&x);

switch(x)
{
case 1:
rrobin(pname,btime,n);
break;
case 2:
exit(0);
break;
}

printf("\n\n if you want to continue press 1:");


scanf("%d",&z);
}
}
rrobin(int pname[],int btime[],int n)
{
int tslice;
j=0;

printf("\n round robin scheduling");


printf("enter the time slice");
scanf("%d",&tslice);
printf("process name\t remaining time \ttotal time");
while(j<n)
{
for(i=0;i<n;i++)
{
if(btime[i]>0)
{
if(btime[i]>=tslice)
{
ttime+=tslice;
btime[i]=btime[i]-tslice;
printf("\n %d\t\t%d\t\t\t%d",pname[i],btime[i],ttime);
if(btime[i]==0) j++;
}
else
{
ttime+=btime[i];
btime[i]=0;
printf("\n %d\t\t%d\t\t\t%d",pname[i],btime[i],ttime);
}
}
}
}
}
OUTPUT:

[examuser35@localhost Jebastin]$ cc rr.c

[examuser35@localhost Jebastin]$ ./a.out

Enter the number of process: 3

Enter the process name and burst time for the process

Enter the process name 1

Enter the burst time for the process: 1

10

Enter the process name 2

Enter the burst time for the process: 2

10

Enter the process name 3

Enter the burst time for the process: 3

10

Press 1.round robin

2.exit

Process name Remaining time Total

1 5 5

2 5 10

3 5 15

1 0 20

2 0 25

3 0 30

If you want to continue press 1

0
Result:
Experiment Date : 09/09/2024 Page No…

Exercise Title : 10. USING PIPES TO CALCULATE NCR with APPLICATIONS OF


FUNCTIONS.

Aim:

Algorithm:
Program:

#!/bin/bash
fact()
{
i=1
a=1
while [ $i -le $x ]
do
a=`expr $a \* $i`
i=`expr $i + 1`
done
}
echo “Enter the N value:”
read n
echo “Enter the R value:”
read r
x=$n
fact
nf=$a
x=$r
fact
rf=$a
x=`expr $n - $r`
fact
nrf=$a
res=`expr $rf \* $nrf`
res=`expr $nf / $res`
echo “the combination of $n C $r is $res.”
Output:
Enter the N value:
5
Enter the R value:
3
The combination of 5 C 3 is 10

Result:

You might also like