Cse Os Manual
Cse Os Manual
No 1
13.02.2021 Basic Linux commands
Aim:
To execute basic commands in Linux Commands:
1. Creating a file:
Syntax: $ cat> filename
The cat command reads the standard input (the keyboard) and the > redirects the Output,
which normally goes to the screen, into a file
E.g. $ cat > myfile
Output
[mtec11@telnet ~]$ cat > display_file
Mtec11
Good Girl
Study well
Eat well
Sleep well
Output
[mtec11@telnet ~]$ cat display_file
Mtec11
Good Girl
Study well
Eat well
Sleep well
Output
[mtec11@telnet ~]$ cat >> display_file
Thus mtec11 can be crowned the best
1
[mtec11@telnet ~]$ cat display_file
Mtec11
Good Girl
Study well
Eat well
Sleep well
Thus mtec11 can be crowned the best
Output
The cp command makes a copy of file1 in the current working directory and
calls it file2 or if the file2 already exists then the contents in file2 is overwritten by contents in
file1 without any warning.
Syntax: $ cp file1 file2
E.g., $ cp myfile1 myfile2
Output
[mtec11@telnet ~]$ cp concatenated_file copied_file
[mtec11@telnet ~]$ cat copied_file
Mtec11
Good Girl
Study well
Eat well
2
Sleep well
Thus mtec11 can be crowned the best
This a new file created to demonstrate concatenation of files
Output
Output
Output
[mtec11@telnet ~]$ mkdir exjayan
3
[mtec11@telnet ~]$ cd exjayan
[mtec11@telnet exjayan]$
Output
[mtec11@telnet exjayan]$ cd
[mtec11@telnet ~]$ rmdir exjayan
[mtec11@telnet ~]$ cd exjayan
-bash: cd: exjayan: No such file or directory
Output
Output
[mtec11@telnet ~]$ cd ex
[mtec11@telnet ex]$
Output
[mtec11@telnet ~]$ cd ex
[mtec11@telnet ex]$
4
The cd command with no argument is used to exit from current directory.
E.g.,$ cd
Output
[mtec11@telnet ex]$ cd
[mtec11@telnet ~]$
Output
[mtec11@telnet ~]$ ls -a
. matrix
.. newcountries
alpha_numbers new_file
a.out newsortcountries
Arithmetic_Manipulation nish
Arithmetic_Operations nisha
.bash_history numbers
.bash_logout Output_File
.bash_profile Palindrome1.c
5
.bashrc Palindrome.c
Biggest_Two Palindrome_Checking.c
.canna .Palindrome_Checking.c.swp
concatenated_file Read_File
Count_Characters.c Reverse_file.c
Count_Characters_File.c Reverse_File.c
countries salary
countries_sort Salary
Display_20Lines.c Sort
display_file sortcountries
Display_File_Contents.c String_Comparison
.Display_File_Contents.swo Student
.Display_File_Contents.swp Student1
.emacs Sum_Even_Numbers
greetings Sum_N_Natural_Numbers
.gtkrc Transpose_Matrix.c
hello unix_file
ignisha .viminfo
Input_File .viminfo.tmp
.kde ex
Largest_Three .xemacs
lynx_bookmarks.html .zshrc
Output
[mtec11@telnet ~]$ ls -t
ex Count_Characters_File.c nisha
concatenated_file Display_File_Contents.c alpha_numbers
new_file Input_File numbers
display_file Reverse_File.c countries_sort
Arithmetic_Operations Display_20Lines.c newsortcountries
Output_File Sum_N_Natural_Numbers sortcountries
Reverse_file.c Biggest_Two newcountries
matrix greetings countries
a.out Sum_Even_Numbers lynx_bookmarks.html
Transpose_Matrix.c Arithmetic_Manipulation Student1
Palindrome_Checking.c String_Comparison Student
Palindrome.c Largest_Three salary
Palindrome1.c hello Sort
Count_Characters.c nish Salary
6
Read_File ignisha unix_file
Output
Output
Output
[mtec11@telnet ~]$ wc -w new_file
10 new_file
Output
[mtec11@telnet ~]$ wc -c new_file
62 new_file
Output
7
[mtec11@telnet ~]$ file new_file
new_file: ASCII text
8
Ex No 2a
08.03.2021 FCFS scheduling algorithm
Aim:
To write a C program to implement FCFS scheduling algorithm
Algorithm:
Get the number of process
Get the burst time for the process
Arrange the process in the first come, first serve and complete the process
Calculate the waiting time and turn-around time and find their averages
Program:
#include<stdio.h>
int main()
{
int i,j,n,ch,ts,count,ptm,flag;
float tot_wt,tot_tn;
struct process
{
int pno;
int btime;
int wtime;
int ttime;
int rrtime;
int pri;
}p[10],temp;
printf("FIFO scheduling\n");
tot_wt=tot_tn=0;
printf("Enter the no of process\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
p[i].pno=i+1;
9
printf("Enter the burst time of process %d\n",i+1);
scanf("%d",&p[i].btime);
}
p[0].wtime=0;
p[0].ttime=p[0].btime;
tot_tn=p[0].btime;
for(i=1;i<n;i++)
{
p[i].wtime=p[i-1].ttime;
p[i].ttime=p[i].wtime+p[i].btime;
tot_wt+=p[i].wtime;
tot_tn+=p[i].ttime;
}
printf("Process no \tBurst time \t Waiting time \tTurnaroundtime\n");
for(i=0;i<n;i++)
printf("%d\t\t%d\t\t%d\t\t%d\n",p[i].pno,p[i].btime,p[i].wtime,p[i].ttime);
printf("Avg waiting time %f\n",tot_wt/n);
printf("Avg turnaround time %f\n",tot_tn/n);
}
Output:
[firstmca1@fxtelnetserver ~]$ gcc fcfs.c
[firstmca1@fxtelnetserver ~]$ ./a.out
FIFO scheduling
Enter the no of process
4
Enter the burst time of process 1
2
Enter the burst time of process 2
12
Enter the burst time of process 3
3
10
Enter the burst time of process 4
10
Process no Burst time Waiting time Turnaroundtime
1 2 0 2
2 12 2 14
3 3 14 17
4 10 17 27
Avg waiting time 8.250000
Avg turnaround time 15.000000
Result:
Thus the C program for FCFS scheduling is done and the output is verified successfully.
11
Ex No 2b
08.03.2021 SJF scheduling algorithm
Aim:
To write a C program to implement SJF scheduling algorithm
Algorithm:
Get the number of process as input
Get the burst time for each process
Arrange the process with minimum burst time to execute at first
Complete the processes and calculate their waiting and turn-around time and their
averages.
Program:
#include<stdio.h>
int main()
{
int i,j,n,ch,ts,count,ptm,flag;
float tot_wt,tot_tn;
struct process
{
int pno;
int btime;
int wtime;
int ttime;
int rrtime;
int pri;
}p[10],temp;
printf("SJF scheduling\n");
tot_wt=tot_tn=0;
printf("Enter the no of process\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
12
p[i].pno=i+1;
printf("Enter the burst time of process %d\n",i+1);
scanf("%d",&p[i].btime);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(p[i].btime>p[j].btime)
{
temp=p[i];
p[i]=p[j];
p[j]=temp;
}
}
}
p[0].wtime=0;
p[0].ttime=p[0].btime;
tot_tn=p[0].btime;
for(i=1;i<n;i++)
{
p[i].wtime=p[i-1].ttime;
p[i].ttime=p[i].wtime+p[i].btime;
tot_wt+=p[i].wtime;
tot_tn+=p[i].ttime;
}
printf("Process no \tBurst time \t Waiting time \tTurnaroundtime\n");
for(i=0;i<n;i++)
printf("%d\t\t%d\t\t%d\t\t%d\n",p[i].pno,p[i].btime,p[i].wtime,p[i].ttime);
printf("Avg waiting time %f\n",tot_wt/n);
printf("Avg turnaround time %f\n",tot_tn/n);
13
}
Output:
[firstmca1@fxtelnetserver ~]$ ./a.out
SJF scheduling
Enter the no of process
4
Enter the burst time of process 1
2
Enter the burst time of process 2
12
Enter the burst time of process 3
3
Enter the burst time of process 4
10
14
Ex No 2c
08.03.2021 Priority scheduling algorithm
Aim:
To write a C program to implement priority scheduling
Algorithm:
Get the number of process as input
Get the priority and the burst time for each process
Arrange the process and execute based on their priority such that, lower the number,
higher the priority.
Calculate the waiting and turn-around time and their averages.
Program:
#include<stdio.h>
void main()
{
int i,j,n,ch,ts,count,ptm,flag;
float tot_wt,tot_tn;
struct process
{
int pno;
int btime;
int wtime;
int ttime;
int rrtime;
int pri;
}p[10],temp;
printf("Priority Scheduling\n");
tot_wt=tot_tn=0;
printf("Enter the no of processes\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
15
p[i].pno=i+1;
printf("Enter the Burst time of process %d\n",i+1);
scanf("%d",&p[i].btime);
printf("Enter the Priority of process %d\n",i+1);
scanf("%d",&p[i].pri);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(p[i].pri>p[j].pri)
{
temp=p[i];
p[i]=p[j];
p[j]=temp;
}}}
p[0].wtime=0;
p[0].ttime=p[0].btime;
tot_tn=p[0].btime;
for(i=1;i<n;i++)
{
p[i].wtime=p[i-1].ttime;
p[i].ttime=p[i].wtime+p[i].btime;
tot_wt+=p[i].wtime;
tot_tn+=p[i].ttime;
}
printf("Process no \tPriority\tBurst time \tWaiting time\tTurnaroundtime\n");
for(i=0;i<n;i++)
printf("%d\t\t%d\t\t%d\t\t%d\t\t%d\n",p[i].pno,p[i].pri,p[i].btime,p[i].wtime,p[
i].ttime);
printf("Avg waiting time %f\n",tot_wt/n);
16
printf("Avg turn around time %f\n",tot_tn/n);
}
Output:
[firstmca1@fxtelnetserver ~]$ ./a.out
Priority Scheduling
Enter the no of processes
3
Enter the Burst time of process 1
2
Enter the Priority of process 1
5
Enter the Burst time of process 2
3
Enter the Priority of process 2
2
Enter the Burst time of process 3
6
Enter the Priority of process 3
1
Process no Priority Burst time Waiting time Turnaroundtime
3 1 6 0 6
2 2 3 6 9
1 5 2 9 11
Avg waiting time 5.000000
Avg turn around time 8.666667
Result:
Thus the C program for priority scheduling is done and the output is verified successfully.
17
Ex No 2d
08.03.2021 Round Robin scheduling algorithm
Aim:
To write a C program for round robin scheduling
Algorithm:
Get the number of process as input
Get the time slice and the burst time for each process
Complete the process based on their time slice and when the time slice expires, complete
the next process for the given time slice
Calculate the waiting and turn-around time and their averages
Program:
#include<stdio.h>
void main()
{
int i,j,n,ch,ts,count,ptm,flag;
float tot_wt,tot_tn;
struct process
{
int pno;
int btime;
int wtime;
int ttime;
int rrtime;
int pri;
}p[10],temp;
ptm=0;
printf("RR Scheduling\n");
tot_wt=tot_tn=0;
printf("Enter the no of processes\n");
scanf("%d",&n);
printf("Enter the Time slice\n");
18
scanf("%d",&ts);
for(i=0;i<n;i++)
{
p[i].pno=i+1;
p[i].wtime=p[i].ttime=0;
printf("Enter the Burst time of process %d\n",i+1);
scanf("%d",&p[i].btime);
p[i].rrtime=p[i].btime;
}
do
{
flag=0;
for(i=0;i<n;i++)
{
count=p[i].btime;
if(count>0)
{
flag=1;
count=(count>=ts)?ts:count;
printf("Process %d from %d to %d\n",p[i].pno,ptm,ptm+count);
p[i].wtime+=ptm-p[i].ttime;
ptm=ptm+count;
p[i].ttime=ptm;
p[i].btime-=count;
}
}
}while(flag);
for(i=0;i<n;i++)
{
tot_wt+=p[i].wtime;
tot_tn+=p[i].ttime;
19
}
printf("Process no \tBurst time \tWaiting time \tTurnaroundtime\n");
for(i=0;i<n;i++)
printf("%d\t\t%d\t\t%d\t\t%d\n",p[i].pno,p[i].rrtime,p[i].wtime,p[i].ttime);
printf("Avg waiting time %f\n",tot_wt/n);
printf("Avg turn around time %f\n",tot_tn/n);
}
Output:
[firstmca1@fxtelnetserver ~]$ ./a.out
RR Scheduling
Enter the no of processes
4
Enter the Time slice
2
Enter the Burst time of process 1
6
Enter the Burst time of process 2
5
Enter the Burst time of process 3
4
Enter the Burst time of process 4
8
Process 1 from 0 to 2
Process 2 from 2 to 4
Process 3 from 4 to 6
Process 4 from 6 to 8
Process 1 from 8 to 10
Process 2 from 10 to 12
Process 3 from 12 to 14
Process 4 from 14 to 16
Process 1 from 16 to 18
20
Process 2 from 18 to 19
Process 4 from 19 to 21
Process 4 from 21 to 23
Process no Burst time Waiting time Turnaroundtime
1 6 12 18
2 5 14 19
3 4 10 14
4 8 15 23
Avg waiting time 12.750000
Avg turn around time 18.500000
Result:
Thus a C program for round robin scheduling algorithm is done and the output is verified
successfully.
21
Ex No 3
08.03.2021 Bankers algorithm for Deadlock Avoidance
Aim:
To write a C program to implement Bankers algorithm for deadlock avoidance
Safety Algorithm:
LetWork and Finish be vectors of length m and n, respectively. Initialize
Work = Available and Finish[i] = false for i = 0, 1, ...,n− 1.
Find an index i such that both
a. Finish[i] == false
b. Needi≤Work
If no such i exists, go to step 4.
Work =Work + Allocation
Finish[i] = true
Go to step 2.
If Finish[i] == true for all i, then the system is in a safe state.
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("\n Enter the number of resources : ");
scanf("%d", &rz);
printf("\n 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("\n Enter the number of processes : ");
22
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++) {
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];
23
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("Safe Sequence\n");
printf("\t <");
for (i=0;i<k;i++)
printf(" P[%d] ",output[i]);
printf(">");
getch();
}
Output:
Enter the number of resources : 3
a= 1
b= 5
c= 7
24
abc
P[0] 0 1 0
P[1] 2 0 0
P[2] 3 0 2
P[3] 2 1 1
P[4] 0 0 2
abc
P[0] 7 5 3
P[1] 3 2 2
P[2] 9 0 2
P[3] 2 2 2
P[4] 4 3 3
Result:
Thus a C program to implement Bankers algorithm for deadlock avoidance is done and
the output is verified successfully.
25
Ex.No:4a
15.03.2021 FIFO Page replacement algorithm
Aim:
To write a C program to implement FIFO page replacement
Algorithm:
Get the total number of pages and their reference strings
Get the total number of frames
Assign the first page to the first free frame and when frames are full, replace the frame
for which the page was first assigned.
Calculate the page fault when pages are being replaced and display it.
Program:
#include<stdio.h>
int main()
{
int reference_string[10], page_faults = 0, m, n, s, pages, frames;
printf("\nEnter Total Number of Pages:\t");
scanf("%d", &pages);
printf("\nEnter values of Reference String:\n");
for(m = 0; m < pages; m++)
{
printf("Value No. [%d]:\t", m + 1);
scanf("%d", &reference_string[m]);
}
printf("\nEnter Total Number of Frames:\t");
{
scanf("%d", &frames);
}
int temp[frames];
for(m = 0; m < frames; m++)
{
temp[m] = -1;
26
}
for(m = 0; m < pages; m++)
{
s = 0;
for(n = 0; n < frames; n++)
{
if(reference_string[m] == temp[n])
{
s++;
page_faults--;
}
}
page_faults++;
if((page_faults <= frames) && (s == 0))
{
temp[m] = reference_string[m];
}
else if(s == 0)
{
temp[(page_faults - 1) % frames] = reference_string[m];
}
printf("\n");
for(n = 0; n < frames; n++)
{
printf("%d\t", temp[n]);
}
}
printf("\nTotal Page Faults:\t%d\n", page_faults);
return 0;
}
27
Output:
[firstmca1@fxtelnetserver ~]$ ./a.out
Enter Total Number of Pages: 5
Enter values of Reference String:
Value No. [1]: 4
Value No. [2]: 1
Value No. [3]: 2
Value No. [4]: 4
Value No. [5]: 5
Enter Total Number of Frames: 3
4 -1 -1
4 1 -1
4 1 2
4 1 2
5 1 2
Total Page Faults: 4
Result:
Thus a C program for FIFO page replacement is done and the output is verified successfully
28
Ex.No:4b
15.03.2021 LRU Page replacement algorithm
Aim:
To write a C program for LRU page replacement strategy
Algorithm:
Get the total number of pages and their reference strings
Get the total number of frames
Assign the first page to the first free frame and when frames are full, replace the page that
was least recently used.
Calculate the page fault when pages are being replaced and display it.
Program:
#include<stdio.h>
int findLRU(int time[], int n){
int i, minimum = time[0], pos = 0;
for(i = 1; i < n; ++i){
if(time[i] < minimum){
minimum = time[i];
pos = i;
}
}
return pos;
}
int main()
{
int no_of_frames, no_of_pages, frames[10], pages[30], counter = 0, time[10],
flag1, flag2, i, j, pos, faults = 0;
printf("Enter number of frames: ");
scanf("%d", &no_of_frames);
printf("Enter number of pages: ");
scanf("%d", &no_of_pages);
printf("Enter reference string: ");
29
for(i = 0; i < no_of_pages; ++i){
scanf("%d", &pages[i]);
}
for(i = 0; i < no_of_frames; ++i){
frames[i] = -1;
}
for(i = 0; i < no_of_pages; ++i){
flag1 = flag2 = 0;
for(j = 0; j < no_of_frames; ++j){
if(frames[j] == pages[i]){
counter++;
time[j] = counter;
flag1 = flag2 = 1;
break;
}
}
if(flag1 == 0){
for(j = 0; j < no_of_frames; ++j){
if(frames[j] == -1){
counter++;
faults++;
frames[j] = pages[i];
time[j] = counter;
flag2 = 1;
break;
}
}
}
if(flag2 == 0){
pos = findLRU(time, no_of_frames);
counter++;
30
faults++;
frames[pos] = pages[i];
time[pos] = counter;
}
printf("\n");
for(j = 0; j < no_of_frames; ++j){
printf("%d\t", frames[j]);
}
}
printf("\n\nTotal Page Faults = %d", faults);
return 0;
}
Output:
[firstmca1@fxtelnetserver ~]$ gcc lr.c
[firstmca1@fxtelnetserver ~]$ ./a.out
Enter number of frames: 3
Enter number of pages: 6
Enter reference string: 5 7 5 6 7 3
5 -1 -1
5 7 -1
5 7 -1
5 7 6
5 7 6
3 7 6
Total Page Faults = 4
Result:
Thus a C program for LRU page replacement is done and the output is verified successfully
31
Ex.No:4c
15.03.2021 LFU Page replacement algorithm
Aim:
Algorithm:
Program:
#include<stdio.h>
int main()
scanf("%d", &total_pages);
scanf("%d", &total_frames);
frame[m] = -1;
32
arr[m] = 0;
scanf("%d", &pages[m]);
printf("\n");
arr[pages[m]]++;
time[pages[m]] = m;
flag = 1;
k = frame[0];
if(frame[n] != -1)
hit++;
flag = 0;
frame[n] = pages[m];
33
break;
k = frame[n];
if(flag)
minimum_time = 25;
temp = n;
minimum_time = time[frame[n]];
arr[frame[temp]] = 0;
frame[temp] = pages[m];
printf("%d\t", frame[n]);
34
printf("\n");
return 0;
Output:
5 -1 -1
5 7 -1
5 7 -1
5 7 6
5 7 6
5 7 3
Page Hit: 2
Result:
Thus a C program for LFU replacement algorithm is done and the output is verified successfully.
35
Ex No 5a
Aim:
Algorithm:
Declare the number, names and size of the directories and file names.
Get the values for the declared variables.
Display the files that are available in the directories.
Program:
#include<stdio.h>
struct
char dname[10],fname[10][10];
int fcnt;
}dir;
void main()
int i,ch;
char f[30];
clrscr();
dir.fcnt = 0;
scanf("%s", dir.dname);
while(1)
36
printf("\n\n 1. Create File\t2. Delete File\t3. Search File \n 4. Display Files\t5. Exit\nEnter your
choice -- ");
scanf("%d",&ch);
switch(ch){
scanf("%s",dir.fname[dir.fcnt]);
dir.fcnt++;
break;
scanf("%s",f);
for(i=0;i<dir.fcnt;i++){
if(strcmp(f, dir.fname[i])==0)
strcpy(dir.fname[i],dir.fname[dir.fcnt-1]);
break;}
if(i==dir.fcnt)
else
dir.fcnt--;
break;
scanf("%s",f);
for(i=0;i<dir.fcnt;i++)
37
{
if(strcmp(f, dir.fname[i])==0)
break;
if(i==dir.fcnt)
break;
case 4: if(dir.fcnt==0)
else
for(i=0;i<dir.fcnt;i++)
printf("\t%s",dir.fname[i]);
break;
default: exit(0);
}}
getch();
Output:
38
1. Create File 2. Delete File 3. Search File
File B is deleted
Result:
Thus a C program for single level directory is done and the output is verified successfully.
39
Ex No 5b
Aim:
Algorithm:
Declare the number, names and size of the directories and subdirectories and file names.
Get the values for the declared variables.
Display the files that are available in the directories and subdirectories.
Program:
#include<stdio.h>
struct
char dname[10],fname[10][10];
int fcnt;
}dir[10];
void main()
int i,ch,dcnt,k;
clrscr();
dcnt=0;
while(1)
scanf("%d",&ch);
40
switch(ch)
scanf("%s", dir[dcnt].dname);
dir[dcnt].fcnt=0;
dcnt++;
printf("Directory created");
break;
scanf("%s",d);
for(i=0;i<dcnt;i++)
if(strcmp(d,dir[i].dname)==0)
scanf("%s",dir[i].fname[dir[i].fcnt]);
dir[i].fcnt++;
printf("File created");
break;
if(i==dcnt)
break;
scanf("%s",d);
for(i=0;i<dcnt;i++)
41
{
if(strcmp(d,dir[i].dname)==0)
scanf("%s",f);
for(k=0;k<dir[i].fcnt;k++)
if(strcmp(f, dir[i].fname[k])==0)
dir[i].fcnt--;
strcpy(dir[i].fname[k],dir[i].fname[dir[i].fcnt]);
goto jmp;
goto jmp;
jmp : break;
scanf("%s",d);
for(i=0;i<dcnt;i++)
42
if(strcmp(d,dir[i].dname)==0)
scanf("%s",f);
for(k=0;k<dir[i].fcnt;k++)
if(strcmp(f, dir[i].fname[k])==0)
goto jmp1;
goto jmp1;
jmp1: break;
case 5: if(dcnt==0)
else{
printf("\nDirectory\tFiles");
for(i=0;i<dcnt;i++){
printf("\n%s\t\t",dir[i].dname);
43
for(k=0;k<dir[i].fcnt;k++)
printf("\t%s",dir[i].fname[k]);}}
break;
default:exit(0);
getch();
Output:
Directory created
Directory created
File created
44
Enter name of the file -- A2
File created
File created
Directory Files
DIR1 A1 A2
DIR2 B1
File A2 is deleted
Result:
Thus a C program for two level directory is done and the output is verified successfully.
45