Professional Documents
Culture Documents
OS & SE Lab Manual by chiru
OS & SE Lab Manual by chiru
OPERATING SYSTEMS
AND
SOFTWARE ENGINEERING LAB
Regulations : GRBT-20
Branch : CSE(CS)
List of Experiments
CourseOutcomes:
CO-1: Implement various CPU scheduling, page replacement and disk scheduling algorithms.
CO-2: Implement various system calls.
CO-3: Implement Bankers algorithm for Dead Lock Avoidance and Prevention
CO-4: Implement the file allocation strategies
CO-5: Develop function oriented and object-oriented software design using tools like
rationalrose.
CO-6: Design test cases for software testing
Exp. No. Name of the Experiment Page No
Implement a C program for FCFS
1(a) Process Scheduling Algorithm 1-2
1. Practical(s) shall be evaluated for 100 marks out of which 50 marks shall be
for internal
assessment and the remaining 50 marks shall be for summative assessment.
2. Award of 50 marks for internal assessment shall be done as follows:
a. A maximum of 25 marks shall be assigned by continuous evaluation,
day to day experimental work.
b. A maximum of 25 marks shall be awarded by conducting TWO
internal practical examinations, one at the middle of the semester and
the other at the end of the semester. There shall be two examiners for
each internal examination. One shall be the faculty member concerned
and the other shall be an internal faculty member nominated by the
HoD. Out of the two, the internal practical examination with highest
score shall be given a weightage of 80% and the other the weightage of
20%.
The evaluation is as follows
I. Continuous evaluation - 25 marks
II. Internal Laboratory Exam1 - 25 marks
III. Internal Laboratory Exam2 - 25 marks
b) Exam 20 marks
i. Experiments write up 10 out of 20
ii. Result and Graphs 10 out of 20
b) Viva voice 5 marks
I. Continuous evaluation - 25 marks
a) Day to day evaluation - 20 marks
Each experiment / program will be evaluated for 20 marks.
The splitting of marks is as follows
i) Attendance – 5 marks
The student should attend the lab regularly; if he/she is absent he/she will be
losing 5 marks.
ii) Experiments and observation
The student should complete the program within the assigned time otherwise he /
she will be losing 5 marks.
iii) Experiment result will carry 5 marks.
iv) Record 5 marks
Algorithm
1. Start
2. Declare the array size
3. Read the number of processes to be inserted
4. Read the Burst times of processes
5. Calculate the waiting time of each process
wt[i+1]=bt[i]+wt[i]
6. Calculate the turnaround time of each process
tt[i+1]=tt[i]+bt[i+1]
7. Calculate the average waiting time and average turnaround time.
8. Display the values
9. Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main(){
int i,n,pro[5],bt[10],wt[10],tat[10],w1=0,t1=0;
float avgwt,avgtat;
printf("Enter no of processes::\n");
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&bt[i]);
for(i=0;i<n;i++){
wt[0]=0;
1|P ag e
tat[0]=bt[0];
wt[i+1]=bt[i]+wt[i];
tat[i+1]=tat[i]+bt[i+1];
w1=w1+wt[i];
t1=t1+tat[i];
avgwt=w1/n;
avgtat=t1/n;
printf("\nProcesses\tBursttime\tWaitingtime\tTurnaroundtime\n");
for(i=0;i<n;i++){
OUTPUT:
Enter no of processes::
2|P ag e
4
10
Processes BursttimeWaitingtimeTurnaroundtime
1 7 0 7
2 3 7 10
3 4 10 14
4 10 14 24
ALGORITHM
1. Start
2. Declare the array size
3. Read the number of processes to be inserted
4. Read the Burst times of processes
5. Sort the Burst times in ascending order and process with shortest burst time is first
executed.
6. Calculate the waiting time of each process
wt[i+1]=bt[i]+wt[i]
7. Calculate the turnaround time of each process
tt[i+1]=tt[i]+bt[i+1]
8. Calculate the average waiting time and average turnaround time.
9. Display the values
10. Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
3|P ag e
int i,j,bt[10],temp,n,wt[10],tat[10];
float w1=0,t1=0;
float avgwt,avgtat;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&bt[i]);
for(i=0;i<n;i++)
for(j=i;j<n;j++)
if(bt[i]>bt[j])
temp=bt[i];
bt[i]=bt[j];
bt[j]=temp;
for(i=0;i<n;i++)
wt[0]=0;
tat[0]=bt[0];
wt[i+1]=bt[i]+wt[i];
4|P ag e
tat[i+1]=tat[i]+bt[i+1];
w1=w1+wt[i];
t1=t1+tat[i];
avgwt=w1/n;
avgtat=t1/n;
for(i=0;i<n;i++){
OUTPUT:
5|P ag e
4
10
Processes BursttimeWaitingtimeTurnAroundtime
1 3 0 3
2 4 3 7
3 7 7 14
4 10 14 24
6|P ag e
(c)Implement a C program for Priority Process Scheduling Algorithm
ALGORITHM
1. Start
2. Declare the array size
3. Read the number of processes to be inserted
4. Read the Priorities of processes
5. Sort the priorities and Burst times in ascending order
5. Calculate the waiting time of each process
wt[i+1]=bt[i]+wt[i]
6. Calculate the turnaround time of each process
tt[i+1]=tt[i]+bt[i+1]
6. Calculate the average waiting time and average turnaround time.
7. Display the values
8. Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
int i,j,pno[10],prior[10],bt[10],n,wt[10],tat[10],w1=0,t1=0,s;
float avgwt,avgtat;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&bt[i]);
7|P ag e
printf("Enter the priority of process %d:",i+1);
scanf("%d",&prior[i]);
pno[i]=i+1;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(prior[i]<prior[j])
s=prior[i];
prior[i]=prior[j];
prior[j]=s;
s=bt[i];
bt[i]=bt[j];
bt[j]=s;
s=pno[i];
pno[i]=pno[j];
pno[j]=s;
for(i=0;i<n;i++)
8|P ag e
wt[0]=0;
tat[0]=bt[0];
wt[i+1]=bt[i]+wt[i];
tat[i+1]=tat[i]+bt[i+1];
w1=w1+wt[i];
t1=t1+tat[i];
avgwt=w1/n;
avgtat=t1/n;
for(i=0;i<n;i++){
OUTPUT:
The process 1:
The process 2:
9|P ag e
Enter the priority of process 2:0
The process 3:
The process 4:
2 0 3 0 3
1 1 7 3 10
4 2 10 10 20
3 3 4 20 24
ALGORITHM
1. Start
2. Declare the array size
3. Read the number of processes to be inserted
4. Read the burst times of the processes
5. Read the Time Quantum
6. If the burst time of a process is greater than time Quantum
then subtract time quantum form the burst time
else assign the burst time to time quantum.
7. Calculate the average waiting time and turnaround time of the
processes.
8. Display the values
9. Stop
10 | P a g e
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int st[10],bt[10],wt[10],tat[10],n,tq;
int i,count=0,t_wt=0,t_tat=0,temp,sq=0;
float avgwt=0.0,avgtat=0.0;
printf("Enter number of processes:");
scanf("%d",&n);
printf("Enter burst time for sequences:\n");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
st[i]=bt[i];
}
printf("Enter time quantum:");
scanf("%d",&tq);
while(1)
{
for(i=0,count=0;i<n;i++)
{
temp=tq;
if(st[i]==0)
{
count++;
continue;
}
if(st[i]>tq)
st[i]=st[i]-tq;
else
if(st[i]>=0)
{
temp=st[i];
st[i]=0;
}
sq=sq+temp;
tat[i]=sq;
}
11 | P a g e
if(n==count)
break;
}
for(i=0;i<n;i++)
{
wt[i]=tat[i]-bt[i];
t_wt=t_wt+wt[i];
t_tat=t_tat+tat[i];
}
avgwt=t_wt/n;
avgtat=t_tat/n;
printf("Process_no Burst time Wait time Turnaround time");
for(i=0;i<n;i++)
printf("\n%d\t %d\t %d\t %d",i+1,bt[i],wt[i],tat[i]);
printf("\nAverage waiting time is %f",avgwt);
printf("\nAverageTurn around time is %f",avgtat);
}
OUTPUT:
12 | P a g e
EXPERIMENT NO: 02
PROGRAM:
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdlib.h>
int main()
{
int pid;
pid=fork();
if(pid<0)
{
printf("\nfork failed\n");
exit(-1);
}
else if(pid==0)
{
printf("welcome to parent");
execlp("/bin/ls","ls","-1",NULL);
}
else
{
wait(NULL);
printf("\nchild complete\n");
exit(0);
13 | P a g e
}}
OUTPUT
guest-glcbIs@ubuntu:~$gcc –o lsc.outlsc.c
guest-glcbIs@ubuntu:~$./lsc.out
total 100
-rwxrwx—x 1 guest-glcbls guest-glcbls 140 2012-07-06 14:55 f1
drwxrwxr-x 4 guest-glcbls guest-glcbls 140 2012-07-06 14:40 dir1
child complete
14 | P a g e
EXPERIMENT NO: 03
Concept:
In this the memory is divided in two parts and process is fit into it. The process which is best
suited in to it is placed in the particular memory where it suits. We have to check memory
partition. If it suits, its status should be changed
ALGORITHM:
Step1: Start the process.
Step2: Declare variables.
Step3: Enter total memory sizems.
Step4: Allocate memory for os.
Ms=ms-os
Step5: Read the no partition to be divided n Partition size=ms/n.
Step6: Read the process no and process size.
Step 7: If process size is less than partition size the process. While allocating update memory
wastage-external fragmentation.
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int ms, bs, nob, ef,n, mp[10],tif=0;
int i,p=0;
printf("Enter the total memory available (in Bytes) -- ");
scanf("%d",&ms);
15 | P a g e
printf("\nEnter the number of processes -- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\t\tNO\t\t---");
else
{
printf("\t\tYES\t%d",bs-mp[i]);
tif = tif + bs-mp[i];
p++;
}
}
if(i<n)
printf("\nMemory is Full, Remaining Processes cannot be accomodated");
printf("\n\nTotal Internal Fragmentation is %d",tif);
printf("\nTotal External Fragmentation is %d",ef);
return 0;}
16 | P a g e
OUTPUT:
17 | P a g e
b) Write a C program to simulate Multi-programming with a variable number of tasks
(MVT)
PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
{
int ms,mp[10],i, temp,n=0;
char ch = 'y';
printf("\nEnter the total memory available (in Bytes)-- ");
scanf("%d",&ms);
temp=ms;
for(i=0;ch=='y';i++,n++)
{
printf("\nEnter memory required for process %d (in Bytes) -- ",i+1);
scanf("%d",&mp[i]);
if(mp[i]<=temp)
{
printf("\nMemory is allocated for Process %d ",i+1);
temp = temp - mp[i];
}
else
{
printf("\nMemory is Full");
break;
}
printf("\nDo you want to continue(y/n) -- ");
scanf(" %c", &ch);
}
printf("\n\nTotal Memory Available -- %d", ms);
printf("\n\n\tPROCESS\t\t MEMORY ALLOCATED ");
for(i=0;i<n;i++)
printf("\n \t%d\t\t%d",i+1,mp[i]);
printf("\n\nTotal Memory Allocated is %d",ms-temp);
printf("\nTotal External Fragmentation is %d",temp);
}
18 | P a g e
OUTPUT:
2 400
Total Memory Allocated is 700
Total External Fragmentation is 300
19 | P a g e
EXPERIMENT NO: 04
PROGRAM
#include<stdio.h>
#include<conio.h>
void main() {
int
k=0,output[10],d=0,t=0,ins[5],i,avail[5],allocated[10][5],need[10][5],MAX[10][5],pno,P[10],j,rz
, count=0;
printf("Enter the number of resources : ");
scanf("%d", &rz);
printf("Enter the max instances of each resources :\n");
for (i=0;i<rz;i++) {
avail[i]=0;
printf("%c= ",(i+97));
scanf("%d",&ins[i]);
}
printf("Enter the number of processes : ");
scanf("%d", &pno);
printf("\n Enter the allocation matrix \n ");
for (i=0;i<rz;i++)
printf(" %c",(i+97));
printf("\n");
for (i=0;i <pno;i++) {
P[i]=i;
printf("P[%d] ",P[i]);
for (j=0;j<rz;j++) {
scanf("%d",&allocated[i][j]);
avail[j]+=allocated[i][j];
}
}
printf("\nEnter the MAX matrix \n ");
for (i=0;i<rz;i++) {
printf(" %c",(i+97));
avail[i]=ins[i]-avail[i];
}
printf("\n");
for (i=0;i <pno;i++) {
20 | P a g e
printf("P[%d] ",i);
for (j=0;j<rz;j++)
scanf("%d", &MAX[i][j]);
}
printf("\n");
A: d=-1;
for (i=0;i <pno;i++) {
count=0;
t=P[i];
for (j=0;j<rz;j++) {
need[t][j] = MAX[t][j]-allocated[t][j];
if(need[t][j]<=avail[j])
count++;
}
if(count==rz) {
output[k++]=P[i];
for (j=0;j<rz;j++)
avail[j]+=allocated[t][j];
} else
P[++d]=P[i];
}
if(d!=-1) {
pno=d+1;
goto A;
}
printf("Sequence of Execution :");
for (i=0;i<k;i++)
printf(" P[%d] ",output[i]);
}
OUTPUT
21 | P a g e
P[0] 010
P[1] 200
P[2] 302
P[3] 211
P[4] 002
22 | P a g e
EXPERIMENT NO: 05
PROGRAM
#include<stdio.h>
void main()
{
int max[10][10],a1[10][10],av[10],i,j,k,m,n,ne[10][10],flag=0;
printf("\nEnter the processes and resources :");
scanf("%d%d",&m,&n);
printf("\n Enter the maximum matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&max[i][j]);
}
}
printf("\n Enter allocated matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a1[i][j]);
}
}
printf("\n The need matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
ne[i][j]=max[i][j]-a1[i][j];
printf("\t%d",ne[i][j]);
}
printf("\n");
}
printf("\n Enter available matrix:\n");
for(i=0;i<n;i++)
scanf("%d",&av[i]);
23 | P a g e
printf("\n Maximum matrix\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("\t%d",max[i][j]);
}
printf("\n");
}
printf("\n Allocated matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("\t%d",a1[i][j]);
}
printf("\n");
}
printf("\n Available matrix:\n");
for(i=0;i<n;i++)
{
printf("%d\t",av[i]);
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(av[i]>=ne[i][j])
flag=1;
else
flag=0;
}
}
if(flag==0)
printf("\n Unsafe state");
else
printf("\n safe state");
}
24 | P a g e
OUTPUT
230
Maximum matrix
3 6 8
4 3 3
3 4 4
Allocated matrix:
2 2 3
2 0 3
1 2 4
Available matrix:
2 3 0
safe state
25 | P a g e
EXPERIMENT NO: 06
PROGRAM:
#include<stdio.h>
int main()
{
int i,j,n,a[50],frame[10],no,k,avail,count=0;
printf("Enter the no of pages: ");
scanf("%d",&n);
printf("Enter the page no: ");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
printf("%d\t\t",a[i]);
avail=0;
for(k=0;k<no;k++)
if(frame[k]==a[i])
avail=1;
if (avail==0)
{
26 | P a g e
frame[j]=a[i];
j=(j+1)%no;
count++;
for(k=0;k<no;k++)
printf("%d\t",frame[k]);
}
printf("\n");
}
printf("Page Fault Is %d",count);
return 0;
OUTPUT:
Enter the no of pages: 7
Enter the page no: 1 3 0 3 5 6 3
Enter the no of page frames: 3
PAGE NO PAGE FRAMES
1 1 -1 -1
3 1 3 -1
0 1 3 0
3
5 5 3 0
6 5 6 0
3 5 6 3
Page Fault Is 6
27 | P a g e
b) Write a C program to simulate the LRU page replacement algorithm
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int i, j , k, min, rs[25], m[10], count[10], flag[25], n, f, pf=0, next=1;
printf("Enter the no of pages: ");
scanf("%d",&n);
printf("Enter the page nos: ");
for(i=0;i<n;i++)
{
scanf("%d",&rs[i]);
flag[i]=0;
}
printf("Enter the number of frames: ");
scanf("%d",&f);
for(i=0;i<f;i++)
count[i]=0;
m[i]=-1;
}
printf("\n Page Frames\n");
for(i=0;i<n;i++)
{
for(j=0;j<f;j++)
{
28 | P a g e
if(m[j]==rs[i])
{
flag[i]=1;
count[j]=next;
next++;
}
if(flag[i]==0)
{
if(i<f)
{ m[i]=rs[i];
count[i]=next;
next++;
}
else
{ min=0;
for(j=1;j<f;j++)
if(count[min] > count[j])
min=j;
m[min]=rs[i];
count[min]=next;
next++;
}
pf++;
}
for(j=0;j<f;j++)
29 | P a g e
printf("%d\t", m[j]);
printf("\n");
}
printf("\nNo of page faults using LRU are %d",pf);}
OUTPUT:
Enter the no of pages: 7
Enter the page nos: 1 3 0 3 5 6 3
Enter the number of frames: 3
Page Frames
1 -1 -1
1 3 -1
1 3 0
1 3 0
5 3 0
5 3 6
5 3 6
No of page faults using LRU are 5
30 | P a g e
c)Write a C program to simulatetheLFUpage replacement algorithm
PROGRAM
#include<stdio.h>
int main()
int nf, np, frames[10], pages[30], temp[10], flag1, flag2, flag3, i, j, k, pos, max, faults = 0;
scanf("%d", &nf);
scanf("%d", &np);
scanf("%d", &pages[i]);
frames[i] = -1;
flag1 = flag2 = 0;
31 | P a g e
for(j = 0; j <nf; ++j){
if(frames[j] == pages[i]){
flag1 = flag2 = 1;
break;
if(flag1 == 0){
if(frames[j] == -1){
faults++;
frames[j] = pages[i];
flag2 = 1;
break;
if(flag2 == 0){
flag3 =0;
temp[j] = -1;
if(frames[j] == pages[k]){
32 | P a g e
temp[j] = k;
break;
if(temp[j] == -1){
pos = j;
flag3 = 1;
break;
if(flag3 ==0){
max = temp[0];
pos = 0;
max = temp[j];
pos = j;
33 | P a g e
frames[pos] = pages[i];
faults++;
printf("\n");
printf("%d\t", frames[j]);
return 0;}
OUTPUT
2 -1 -1
2 3 -1
2 3 4
2 3 4
1 3 4
1 3 4
7 3 4
5 3 4
34 | P a g e
5 3 4
5 3 4
35 | P a g e
EXPERIMENT NO: 07
PROGRAM
#include<stdio.h>
void main()
for(i=0;i<50;i++)
f[i]=0;
x: count=0;
scanf("%d%d", &st,&len);
for(k=st;k<(st+len);k++)
if(f[k]==0)
count++;
if(len==count)
for(j=st;j<(st+len);j++)
if(f[j]==0)
f[j]=1;
printf("%d\t%d\n",j,f[j]);
36 | P a g e
if(j!=(st+len-1))
else
scanf("%d", &c);
if(c==1)
goto x;
OUTPUT
1 1
2 1
3 1
4 1
5 1
6 1
37 | P a g e
b)Write a C program to simulatethe Indexed File allocation strategy
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
for(i=0;i<50;i++)
f[i]=0;
scanf("%d",&ind);
if(f[ind]!=1)
printf("Enter no of blocks needed and no of files for the index %d on the disk : \n", ind);
scanf("%d",&n);
else
goto x;
y: count=0;
for(i=0;i<n;i++)
38 | P a g e
scanf("%d", &index[i]);
if(f[index[i]]==0)
count++;
if(count==n)
for(j=0;j<n;j++)
f[index[j]]=1;
printf("Allocated\n");
printf("File Indexed\n");
for(k=0;k<n;k++)
printf("%d-------->%d : %d\n",ind,index[k],f[index[k]]);
else
goto y;
scanf("%d", &c);
if(c==1)
goto x;
39 | P a g e
OUTPUT
Enter no of blocks needed and no of files for the index 5 on the disk :
1234
Allocated
File Indexed
5-------->1 : 1
5-------->2 : 1
5-------->3 : 1
5-------->4 : 1
40 | P a g e
c)Write a C program to simulatethe Linked File allocation strategy
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
for(i=0;i<50;i++)
f[i]=0;
scanf("%d",&p);
for(i=0;i<p;i++)
scanf("%d",&a);
f[a]=1;
scanf("%d%d", &st,&len);
k=len;
if(f[st]==0)
for(j=st;j<(st+k);j++)
41 | P a g e
if(f[j]==0)
f[j]=1;
printf("%d-------->%d\n",j,f[j]);
else
k++;
else
scanf("%d", &c);
if(c==1)
goto x;
else
exit(0);
OUTPUT
42 | P a g e
3 Block is already allocated
4-------->1
5 Block is already allocated
6-------->1
7-------->1
Do you want to enter more file(Yes - 1/No - 0)
0
43 | P a g e
EXPERIMENT NO: 08
PROGRAM
#include<stdio.h>
#include<stdlib.h>
int main()
int r[100],i,n,Tst=0,initial;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&r[i]);
scanf("%d",&initial);
for(i=0;i<n;i++)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
return 0;
44 | P a g e
}
OUTPUT
50
PROGRAM
#include<stdio.h>
#include<stdlib.h>
int main()
int r[100],i,j,n,Tst=0,initial,size,move;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&r[i]);
45 | P a g e
printf("Enter initial head position\n");
scanf("%d",&initial);
scanf("%d",&size);
printf("Enter the head movement direction for high 1 and for low 0\n");
scanf("%d",&move);
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
if(r[j]>r[j+1])
int temp;
temp=r[j];
r[j]=r[j+1];
r[j+1]=temp;
int index;
for(i=0;i<n;i++)
46 | P a g e
if(initial<r[i])
index=i;
break;
if(move==1)
for(i=index;i<n;i++)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
Tst=Tst+abs(size-r[i-1]-1);
initial = size-1;
for(i=index-1;i>=0;i--)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
47 | P a g e
// if movement is towards low value
else
for(i=index-1;i>=0;i--)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
Tst=Tst+abs(r[i+1]-0);
initial =0;
for(i=index;i<n;i++)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
return 0;
48 | P a g e
OUTPUT
50
199
Enter the head movement direction for high 1 and for low 0
PROGRAM
#include<stdio.h>
#include<stdlib.h>
int main()
int r[100],i,j,n,Tst=0,initial,size,move;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&r[i]);
49 | P a g e
printf("Enter initial head position\n");
scanf("%d",&initial);
scanf("%d",&size);
printf("Enter the head movement direction for high 1 and for low 0\n");
scanf("%d",&move);
for(i=0;i<n;i++)
for( j=0;j<n-i-1;j++)
if(r[j]>r[j+1])
int temp;
temp=r[j];
r[j]=r[j+1];
r[j+1]=temp;
int index;
50 | P a g e
for(i=0;i<n;i++)
if(initial<r[i])
index=i;
break;
if(move==1)
for(i=index;i<n;i++)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
Tst=Tst+abs(size-r[i-1]-1);
Tst=Tst+abs(size-1-0);
initial=0;
for( i=0;i<index;i++)
Tst=Tst+abs(r[i]-initial);
51 | P a g e
initial=r[i];
else
for(i=index-1;i>=0;i--)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
Tst=Tst+abs(r[i+1]-0);
Tst=Tst+abs(size-1-0);
initial =size-1;
for(i=n-1;i>=index;i--)
Tst=Tst+abs(r[i]-initial);
initial=r[i];
return 0;}
52 | P a g e
OUTPUT
50
199
Enter the head movement direction for high 1 and for low 0
PROGRAM
#include<stdio.h>
#include<stdlib.h>
int main()
int r[100],i,n,Tst=0,initial,count=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&r[i]);
53 | P a g e
printf("Enter initial head position\n");
scanf("%d",&initial);
while(count!=n)
int min=1000,d,index;
for(i=0;i<n;i++)
d=abs(r[i]-initial);
if(min>d)
min=d;
index=i;
Tst=Tst+min;
initial=r[index];
r[index]=1000;
count++;
return 0;
54 | P a g e
}
OUTPUT
50
55 | P a g e
PART-B (SOFTWARE ENGINEERING)
EXPERIMENT NO:01
DRAW E-R DIAGRAMS, DFD FOR THE PROJECT.
ER DIAGRAMS:
ER model stands for an Entity-Relationship model. It is a high-level data model. This model is
used to define the data elements and relationship for a specified system. In ER modelling, the
database structure is portrayed as a diagram called an entity-relationship diagram.
ENTITY:
An entity may be any object, class, person or place. In the ER diagram, an entity can be
represented as rectangles.
EX: Consider an organization as an example- manager, product, employee, department etc. can
be taken as an entity.
56 | P a g e
ATTRIBUTE:
The attribute is used to describe the property of an entity. Eclipse is used to represent an
attribute.
EX:id, age, contact number, name, etc. can be attributes of a student.
RELATIONSHIP:
A relationship is used to describe the relation between entities. Diamond or rhombus is used to
represent the relationship.
EX:
a. One-to-One Relationship: When only one instance of an entity is associated with the
relationship, then it is known as one-to-one relationship.
EX: A female can marry to one male, and a male can marry to one female.
b. One-to-many relationship: When more than one instance of the entity on the left, and
only one instance of an entity on the right associates with the relationship then it is
known as a many-to-one relationship.
57 | P a g e
EX: Scientist can invent many inventions, but the invention is done by the only
specific scientist.
c. Many-to-one relationship: When more than one instance of the entity on the left, and
only one instance of an entity on the right associates with the relationship then it is
known as a many-to-one relationship. EX: Student
enrolls for only one course, but a course can have many students.
d. Many-to-many relationship: When more than one instance of the entity on the left, and
more than one instance of an entity on the right associates with the relationship then it is
known as a many-to-many relationship.
EX:Employee can assign by many projects and project can have many employees.
58 | P a g e
Course Registration System:
The course registration system helps the students to gather information about a particular course
and then they can easily register themselves in a particular course.
This ER (Entity Relationship) Diagram represents the model of Course Registration System
Entity. The entity-relationship diagram of Course Registration System shows all the visual
instrument of database tables and the relations between Fees, Students, Course, Trainers etc.
Course Registration System entities and their attributes:
Course Entity: Attributes of Course are course_id, course_student_id, course_registration,
course_name, course_type, course_year, course_description)
Fees Entity: Attributes of Fees are fees_id, fees amount, fees_type, fees_description
Syllabus Entity: Attributes of Syllabus are syllabus_id, syllabus_course_id, syllabus_name,
syllabus_type, syllabus_description
Students Entity: Attributes of Students are student_id, student_college_id, student_name,
student_mobile, student_email, student_username, student password, student_address
Registrations Entity: Attributes of Registrations are registration_id, registration_student_id,
registration_name, registration_type, registration_number, registration_date,
registration_description
Trainers Entity: Attributes of Trainers are trainer_id, trainer_course_id, trainer_name,
trainer_mobile, trainer_email, trainer_usemame, trainer_password, trainer_address
59 | P a g e
Students Marks Analyzing System:
Student mark analyzing system has been designed to carry out the mark analysis process in an
educational institution. The results of respective departments can be efficiently computed without
much of manual involvement. This ER (Entity Relationship) Diagram represents the model of
Students Marks Analyzing System Entity The entity-relationship diagram of Students Marks
Analyzing System shows all the visual instrument of database tables and the relations between
Class Exam, Student Teacher etc.
Result Management System entities and their attributes:
Student Entity: Attributes of Student are student_id, student_college_id, student_name, student
mobile, student email, student username, student password, student address
Class Entity: Attributes of Class are class id, class student id, class name, class room, class type,
class description
Subject Entity: Attributes of Subject are subject id, subject_course_id, subject student_id,
subject_name, subject type, subject_description
Exam Entity: Attributes of Exam are exam id, exam student_id, exam roll number,
exam_dateexam_name, exam_typeexam_description Result Entity Attributes of Result are result
id, result student_id, result_name, result_description
Teacher Entity: Attributes of Teacher are teacher_id, teacher_college_id, teacher_name,
teacher_mobile, teacher_email, teacher_username teacher password, teacher address
60 | P a g e
Online Ticket Reservation System: An
online reservation system is a software solution that allows customers to book their reservations
or appointments online via a company's website or app instead of over the phone or in person.
This ER (Entity Relationship) Diagram represents the model of Ticket Reservation System
Entity. The entity-relationship diagram of Ticket Reservation System shows all the visual
instrument of database tables and the relations between Seats Availability, Stations, Trains,
Passengers etc.
61 | P a g e
Passengers Entity: Attributes of Passengers are passenger_id,passenger_name,
passenger_mobile,passenger_email,passenger_username,passenger_password,passenger_address
Stock Maintenance:
This ER (Entity Relationship) Diagram represents the model of Stock Management System
Entity The entity relationship diagram of Stock Management System shows all the visual
instrument of database tables and the relations between Product Bill, Stock, Store etc.
Stock Management System entities and their attributes:
Stock Entity: Attributes of Stock are stock_id, stock items, stock number, stock_type,
stock_description
Product Entity: Attributes of Product are product_id, product_customer_id product items,
product number, product type product description
Product Quality: Entity Attributes of Product Quality are product
quality_idproduct_quality_name, product quality_type product quality description
Bill Entity: Attributes of Bill are bill_id, bill customer_idbill_number, bill type, bill receipt,
bill_description
Customer Entity: Attributes of Customer are customer_id,customer_name, customer_mobile,
customer email, customer_usemame customer password, customer_address
Store Entity: Attributes of Store are store_id, store_name, store type, store_description
62 | P a g e
DATA FLOW DFD:
A data flow diagram (DFD) maps out the flow of information for any process or system. It uses
defined symbols like rectangles, circles and arrows, plus short text labels, to show data inputs,
outputs, storage points and the routes between each destination. They can be used to analyze an
existing system or model a new one. For each data
flow, at least one of the endpoints (source and / or destination) must exist in a process. The
refined representation of a process can be done in another data-flow diagram, which subdivides
this process into sub-processes. The data-flow diagram is a tool that is part of structured
analysis and data modeling.
63 | P a g e
SYMBOLS AND NOTATIONS USED IN DFDS :
Using any convention’s DFD rules or guidelines, the symbols depict the four components of data
flow diagrams.
64 | P a g e
Function/Process: any process that changes the data, producing an output. It might perform
computations, or sort data based on logic, or direct the data flow based on business rules. A short
label is used to describe the process, such as “Submit payment.”
Database/Data store: files or repositories that hold information for later use, such as a database
table or a membership form. Each data store receives a simple label, such as “Orders.”
Flow/Data flow: the route that data takes between the external entities, processes and data stores.
It portrays the interface between the other components and is shown with arrows, typically
labeled with a short data name, like “Billing details.”
65 | P a g e
LEVELS IN DATA FLOW DIAGRAMS (DFD):
DFD(data flow diagram) can be drawn to represent the system of different levels of abstraction.
Higher-level DFDs are partitioned into low levels-hacking more information and functional
elements. Levels in DFD are numbered 0, 1, 2. The main 3 levels in the data flow diagram, are:
0-level DFD, 1-level DFD, and 2-level DFD.
0-level DFD:
It is also known as a context diagram. It’s designed to be an abstraction view, showing the
system as a single process with its relationship to external entities. It represents the entire system
as a single bubble with input and output data indicated by incoming/outgoing arrows.
1-level DFD:
In 1-level DFD, the context diagram is decomposed into multiple bubbles/processes. In this
level, we highlight the main functions of the system and breakdown the high-level process of 0-
level DFD into subprocesses.
2-level DFD:
2-level DFD goes one step deeper into parts of 1-level DFD. It can be used to plan or record the
specific/necessary detail about the system’s functioning.
Progression to level 3, 4 and more is possible, but usually going beyond level 3 is rare.
66 | P a g e
LEVEL-1:
LEVEL-2:
67 | P a g e
68 | P a g e
STUDENTS MARKS ANALYZING SYSTEM:
Student mark analyzing system has been designed to carry out the mark analysis process in an
educational institution. The results of respective departments can be efficiently computed
without much of manual involvement.
LEVEL-0:
LEVEL-1:
LEVEL-2:
69 | P a g e
70 | P a g e
ONLINE TICKET RESERVATION SYSTEM:
An online reservation system is a software solution that allows customers to
book their reservations or appointments online via a company's website or app instead of over
the phone or in person.
LEVEL-0:
LEVEL-1:
71 | P a g e
LEVEL-2:
72 | P a g e
73 | P a g e
STOCK MAINTENANCE:
Stock management is the practice of ordering, storing, tracking, and controlling inventory.
LEVEL-0:
LEVEL-1:
LEVEL-2:
74 | P a g e
75 | P a g e
EXPERIMENT NO: 02
DRAW UML DIAGRAMS FOR THE PROJECT.
UML:
The Unified Modelling Language (UML) is a graphical language for OOAD that gives a
standard way to write a software system’s blueprint. It helps to visualize, specify, construct, and
document the artifacts of an object-oriented system. It is used to depict the structures and the
relationships in a complex system.
Brief History
It was developed in 1990s as an amalgamation of several techniques, prominently OOAD
technique by Grady Booch, OMT (Object Modelling Technique) by James Rumbaugh, and
OOSE (Object Oriented Software Engineering) by Ivar Jacobson. UML attempted to standardize
semantic models, syntactic notations, and diagrams of OOAD.
2) RELATIONSHIPS: Relationships are the connection between things. The four types of
relationships that can be represented in UML are:
Dependency: This is a semantic relationship between two things such that a
change in one thing brings a change in the other
Association: This is a structural relationship that represents a group of links
having common structure and common behavior.
Generalization: This represents a generalization/specialization relationship in
which subclasses inherit structure and behavior from super-classes.
Realization: This is a semantic relationship between two or more classifiers such
that one classifier lays down a contract that the other classifiers ensure to abide
by.
76 | P a g e
3) DIAGRAMS: A diagram is a graphical representation of a system. It comprises of a group
of elements generally in the form of a graph. UML includes nine diagrams in all, namely:
i. Class Diagram
ii. Use Case Diagram
iii. Sequence Diagram
iv. State Chart Diagram
v. Activity Diagram
vi. Object Diagram
vii. Component Diagram
viii. Deployment Diagram
Class Diagram: A class diagram models the static view of a system. It comprises of the
classes, interfaces, and collaborations of a system; and the relationships between them.
Use cases
Actors
Relationships like dependency, generalization, and association
Use case: A use case describes the sequence of actions a system performs yielding
visible results. It shows the interaction of things outside the system with the system
itself. Use cases may be applied to the whole system as well as a part of the system.
Actor: An actor represents the roles that the users of the use cases play. An actor may
be a person (e.g. student, customer), a device (e.g. workstation)
77 | P a g e
Sequence Diagram: Sequence diagrams are interaction diagrams that illustrate the
ordering of messages according to time.
State–Chart Diagrams: A state–chart diagram shows a state machine that depicts the
control flow of an object from one state to another. State-chart diagrams are used for
modeling objects which are reactive in nature.
Activity Diagrams: An activity diagram depicts the flow of activities which are ongoing
non-atomic operations in a state machine. Activities result in actions which are atomic
operations.
78 | P a g e
COURSE REGISTRATION SYSTEM :
The course registration system helps the students to gather information about a particular course
and then they can easily register themselves in a particular course.
USECASE:
79 | P a g e
SEQUENCE DIAGRAM:
STATECHART:
80 | P a g e
81 | P a g e
ACTIVITY DIAGRAM:
82 | P a g e
CLASS DIAGRAM:
83 | P a g e
MARKS ANALYSING SYSTEM:
USECASE:
84 | P a g e
SEQUENCE:
85 | P a g e
STATE CHART:
86 | P a g e
ACTIVITY DIAGRAM:
87 | P a g e
CLASS DIAGRAM:
88 | P a g e
ONLINE TICKET RESERVATION SYSTEM:
USECASE:
89 | P a g e
SEQUENCE:
90 | P a g e
STATE CHART:
91 | P a g e
ACTIVITY DIAGRAM:
92 | P a g e
CLASS DIAGRAM:
93 | P a g e
STOCK MAINTENANCE SYSTEM:
USECASE:
SEQUENCE DIAGRAM:
94 | P a g e
STATE CHART DIAGRAM:
95 | P a g e
ACTIVITY DIAGRAM:
96 | P a g e
CLASS DIAGRAM:
97 | P a g e
EXPERIMENT NO: 03
TEST CASES:
A Test Case is a set of actions executed to verify a particular feature or functionality of your
software application, it contains test steps, test data, precondition, postcondition developed for
specific test scenario to verify any requirement.
The test case includes specific variables or conditions, using which a testing engineer can
compare expected and actual results to determine whether a software product is functioning as
per the requirements of the customer.
Expected Result:
This indicates the result expected after the test case step execution. Upon entering the right login
information, the expected result would be a successful login.
Actual Result and Post-Conditions
As compared to the expected result, we can determine the status of the test case. In the case of
the email login, the user would either be successfully logged in or not. The post-condition is
what happens as a result of the step execution such as being redirected to the email inbox.
Pass/Fail
Determining the pass/fail status depends on how the expected result and the actual result
compare to each other.
Same result = Pass
Different results = Fail
ns and Pre-Conditions:
98 | P a g e
This entails any conditions to be met before test case execution. One example would be requiring
a valid Outlook account for a login.
Test Data:
This relates to the variables and their values in the test case. In the example of an email login, it
would be the username and password for the account.
ECOMMERCE APPLICATION(AMAZON & FLIPKART) TEST CASES:
The e-commerce business is increasing at a rapid pace especially since Covid.
So it is very important to test e-commerce websites and applications such as Amazon and
Flipkart. Regressive testing of e-commerce applications is vital to make your app more robust
and secure.
Effective manualtest strategies should be designed to test eCommerce applications.
ECOMMERCE APPLICATION ARCHITECTURE
An eCommerce application has 4 important elements –
Main Pages: It includes homepage, privacy page, about us page, careers, etc.
Product Pages: It includes different options for the product such as size, color, and other
attributes.
Product Description Pages: It includes title, description, images, add to cart feature and
additional info, etc.
Shopping Cart: The shopping cart page should include payment options and removing a
product from the cart.
an eCommerce website or an application includes different user roles such as customers,
partners, staff, and service agents. Backend infrastructures include rules, analytics, security,
logging, and content management.
Core Functionality includes Content, Marketing, Inventory Management, Orders, and Catalog.
Back-office functionality includes fulfillment, inventory, payment, and Catalog staging.
Core Functionality includes Content, Marketing, Inventory Management, Orders, and Catalog.
Back-office functionality includes fulfillment, inventory, payment, and Catalog staging.\
99 | P a g e
EXPECTED ACTUAL
TC-ID TC-NAME STEPS INPUT DATA STATUS
RESULT RESULT
100 | P a g e
Username: It should accept
Valid 1)Enter valid username
TC-01 shariff@gmail. username Accepting PASS
Username
Com
TC-06
It should not go to Not Going
Submit 1)click on Submit Button NO INPUT next page FAIL
to next page
It should clear
TC-07
username & Clearing
Cancel 1)click on cancel Button NO INPUT password and and on same PASS
remain on same page
page
It should not clear
TC-08
username & Not clearing
Cancel 1)click on cancel Button NO INPUT password and not and not on FAIL
remain on same the same
page page
101 | P a g e
EXPERIMENT NO: 04
DESIGN THE TEST CASES FOR MOBILE APPLICATION (CONSIDER ANY
EXAMPLE FROM APP STORE)
FUNCTIONAL TESTING:
The Functional Testing of Mobile Application is a process of testing functionalities of mobile
applications like user interactions as well as testing the transactions that users might perform.
The main purpose of mobile application functional testing is to ensure the quality, meeting the
specified expectations, reducing the risk or errors and customer satisfaction.
The various factors which are relevant in functional testing are:
Type of application based upon the business functionality usages (banking, gaming,
social or business)
Target audience type (consumer, enterprise, education)
Distribution channel which is used to spread the application (e.g. Apple App Store, Google
play, direct distribution)
The general test scenarios for Functional Testing in a Mobile application are:
1. To validate whether all the required mandatory fields are working as required.
2. To validate that the mandatory fields are displayed in the screen in a distinctive way than
the non-mandatory fields.
3. To validate whether the application works as per as requirement whenever the application
starts/stops.
4. To validate whether the application goes into minimized mode whenever there is an
incoming phone call. In order to validate the same we need to use a second phone, to call
the device.
PERFORMANCE TESTING:
This type of testing’s fundamental objective is to ensure that the application performs acceptably
under certain performance requirements such as access by a huge number of users or the removal
of a key infrastructure part like a database server.
The general test scenarios for Performance Testing in a Mobile application are:
1. To determine whether the application performs as per the requirement under different
load conditions.
2. To determine whether the current network coverage is able to support the application at
peak, average and minimum user levels.
3. To validate whether the response time of the application is as per as the requirements.
4. To validate that the battery consumption, memory leaks, resources like GPS, Camera
performance is well within required guidelines.
5. To validate the application longevity whenever the user load is rigorous.
6. To validate the network performance while moving around with the device.SECURITY
TESTING TEST CASES:
102 | P a g e
The fundamental objective of security testing is to ensure that the application’s data and
networking security requirements are met as per guidelines.
The following are the most crucial areas for checking the security of Mobile applications.
The general test scenarios for security testing in a Mobile application are:
1. To validate that the application is able to withstand any brute force attack which is an
automated process of trial and error used to guess a person’s username, password or
credit-card number.
2. To validate whether an application is not permitting an attacker to access sensitive
content or functionality without proper authentication.
3. To validate that the application has a strong password protection system and it does not
permit an attacker to obtain, change or recover another user’s password.
4. To validate that the application does not suffer from insufficient session expiration.
5. To identify the dynamic dependencies and take measures to prevent any attacker for
accessing these vulnerabilities.
6. To protect the application and the network from the denial of service attacks.
7. To analyze the data storage and data validation requirements.
8. To protect against malicious client side injections.
9. To protect against malicious runtime injections.
103 | P a g e
COMPATIBILITY TESTING TEST CASES:
Compatibility testing on mobile devices is performed to ensure that since mobile devices have
different size, resolution, screen, version and hardware so the application should be tested across
all the devices to ensure that the application works as desired.
The general test scenarios for compatibility testing in a Mobile application are:
1. To validate that the user Interface of the application is as per the screen size of the device,
no text/control is partially invisible or inaccessible.
2. To ensure that the text is readable for all users for the application.
3. To ensure that the call/alarm functionality is enabled whenever the application is running.
The application is minimized or suspended on the event of a call and then whenever the
call stops the application is resumed.
The general test scenarios for recoverability testing in a Mobile application are:
Important Checklist
1. Installation testing (whether the application can be installed in a reasonable amount of
time and with required criterion)
2. Uninstallation testing (whether the application can be uninstalled in a reasonable
amount of time and with required criterion)
3. Network test cases (validation of whether the network is performing under required load
or not, whether the network is able to support all the necessary applications during the
testing procedures)
4. Check Unmapped keys
5. Check application splash screen
6. Continued keypad entry during interrupts and other times like network issues
7. Methods which deal with exiting the application
8. Charger effect while an application is running in the background
9. Low battery and high-performance demand
10. Removal of battery while an application is being performed
11. Consumption of battery by application
104 | P a g e
TEST EXPECTED ACTUAL
STATUS STEPS STATUS
CONDITION RESULT RESULT
1)download and install Mobile app should
mobile app open with in
Verify mobile 2)open mobile app first registration links.
DESIGN app registration time NOT RUN N/A
screen
105 | P a g e
1)download and install Name field should
mobile app be
2)open mobile app first
TYEP: Test box
DESIGN Verifyname field time ACCEPT: Min 3 NOT RUN N/A
3)click on registration
and max 16
link alphabets
4)verify name field VALIDATION:
should provide
1)mobile app Email id field
validation message
download & install should be
if field is empty
2)open mobile app first TYPE: test box
while click on
Verify Email id time Accepts: email ID
DESIGN continue NOT RUN N/A
field 3)click on registration format
link
4)enter name
5)verify email
1)mobile
EXPECTED no field ACTUAL
STEPS should be STATUS TC-ID TYPE
RESULT RESULT
1)Download & Install TYPE: text box
mobile app ACCEPTS:only
2)open mobile app first numeric
time MAX: 10 digits
3)Click on registration VALIDATION: NOT RUN N/A TC-01 SANITY
link should provide
4)Enter name validation
5)Enter Email no. message
1)PASSWORDif field is
6)Verify
1)Download mobile
&number
install empty
field should
whilebeclick
mobile app on
ACCEPTS: continue
2)Open mobile app first button
password
time encrypted all
3)Click registration link characters
NOT RUN N/A TC-02 SANITY
4)Enter name VALIDATION:
5)Enter email ID if empty should
6)Enter mobile number provide validation
106 | P a g e
7)Enter the password message while
1)Download&Install
field 1)mobile
click on continueapp
mobile app should
button redirect
2)Open mobile app for page in order to
first time login with
3)Click on registration Facebook existing
NOT RUN N/A TC-03 MANUAL
link account
4)Click on facebook link 2)should display
accept
1)mobile app
should redirect
google page in
Click on Google link NOT RUN N/A TC-04 MANUAL
order to login with
google existing
account
TEST
TC-ID TYPE STATUS
CONDITION
Verify mobile
TC-05 MANUAL DESIGN
number field
Verify password
TC-06 MANUAL DESIGN
field
107 | P a g e
Verify Facebook
TC-07 MANUAL DESIGN
link
These are the UML diagrams of ATM System which shows the flows between the Balance,
Accounts, Customer Employees, Fixed Deposit.
The main activity involved in this UML Activity Diagram of Banking Management System are
as follows
BALANCE ACTIVITY
ACCOUNTS ACTIVITY
CUSTOMER ACTIVITY
EMPLOYEES ACTIVITY
FIXED DEPOSIT ACTIVITY
USECASE DIAGRAM:
108 | P a g e
SEQUENCE DIAGRAM:
109 | P a g e
STATECHART DIAGRAM:
110 | P a g e
ACTIVITY DIAGRAM:
111 | P a g e
CLASS DIAGRAM:
112 | P a g e