You are on page 1of 47

BABA BANDA SINGH BAHADUR

ENGINEERING COLLEGE

Operating System Lab

Submitted To: Prof. Gurleen Sidhu.


Submitted By: Gaganpreet Singh.
University Roll No: 1900645
Branch / Semester: CSE / 4th
Group: 4C12

1
Index

S.No Practical Name Remark

1. Windows Installation.

2. Ubuntu Installation.

3. Mac Installation.

4. Installation of Linux using Virtual Box

5. Implementation of Linux Command.

6. Implementation of CPU scheduling algorithm - FCFS


to find turnaround time and waiting time.

7. Implementation of CPU scheduling algorithm - SJF


to find turnaround time and waiting time.

8. Implementation of CPU scheduling algorithm –


Round Robin (pre-emptive) to find turn around
time and waiting time.
9. Implementation of CPU scheduling algorithm –
Priority to find turnaround time and waiting time

10. Simulate the Bankers algorithm for deadlock


avoidance and deadlock prevention.

11. Implementing Shell Programming.

2
Practical No.: 1 Windows Installation

Aim: To install windows operating system.

In order to install your copy of the Windows 7 operating systems please make sure to
have the following items:

-Windows 7 Installation disk


-Drivers CD: * Use after installation process if needed.

Step1. Insert the Windows 7 operating system disk into your DVD drive, and then restart
your computer

Step2.You will see a prompt that says ‘Press any key to continue’ after the ZT logo
disappears. When you see this press any key immediately.

Step 3 ‘Starting Windows’ with the Windows7 logo will appear.

Step4. Language options, by default English will be set along with “time and currency
format” and “keyboard or input method”

3
Step 5. Click “Install Now”

Step 6. End User License Agreement (E.U.L.A.), check the box to accept, and click “Next”

Step7. “Which type of installation?”window will appear. Upgrade will be greyed out; the only
option you should be able to choose is Custom (advanced).

Step8. “Where do you want to install windows?” Make sure the partition is highlighted.
4
Step9.Delete the partition by clicking on Drive options (advanced) on the bottom right
corner of the field. Make sure the partition is highlighted and click on Delete. If drive
advanced options is greyed out, then the partition will not have to be deleted.

*NOTE: Deleting the partitions will erase all data on the system

Step10. Disk 0 Unallocated Space should be the only listing at this point. If it is press next, if
not please proceed to delete any additional partitions that may be listed.

Step11. The next screen will show “Installing Windows”. This process should take
approximately 10 minutes after which the system will reboot.

*NOTE: Do not press any keys during this boot up process so as to not disturb the rest of
the installation.

Step12. The next screen will show “Installing Windows” again to complete the installation
process.

5
Step13. “Setup is starting Windows” will appear on the screen, then you will be asked to
create a username and a computer name.

Step 14. The next step will prompt you to create a password for your account (optional)

Step15.The next screen will come up and ask you to choose one of three options: “Use
recommended settings”, “Install important updates only” and “Ask me later”.

6
Step16. This screen will allow you to choose your local time zone and also adjust the date
and time.

Step17. Click on the appropriate location of your computer to enable Windows 7 to apply the
correct network settings.

The installation is done.

Practical No.: 2 Ubuntu Installation

Aim: To install ubuntu operating system.

Follow the below Steps to Install Ubuntu 15.04

Step:1 Download the ISO file using the following links

7
DDownload Ubuntu 15.04
(64-bit)
DDownload Ubuntu 15.04(32-
bit)

Once the iso file has been downloaded, burn it into DVD or USB drive and make it
bootable.

Step:2 Boot your system with Bootable DVD / USB drive.

To start the installation, click on “Install Ubuntu”

Step:3 Check Install Prerequisite

Make sure you have at least 6.6 GB free disk space and if you want to download updates
and third party tools at the installation, check both the boxes and make sure system is
connected to Internet

o Download updates while installing


o Install this third-party software

….

8
Step:4 Select the Installation Type

If your system has new hard drive and if nothing installed on it, then you can choose the
first option “Erase disk & Install Ubuntu”.

If you want LVM based file system, then use third option “Use LVM with new Ubuntu
Installation”

If you want to create customize partition table, the use last option

After the installation your PC will restart and your operating system is ready to use.

Practical No.: 3 Mac Installation

Aim: To install Mac Operating System.

Install of macOS on your Mac using the recovery utility. Make sure your Mac is connected to a
power source and has a steady connection to the internet during the install process.

STEP: 1
Turn on or reboot your Mac. You will access recovery utility this way.
9
Your computer needs access to the internet if you do not have a local copy of macOS.

STEP: 2

Press and hold ⌘Cmd+ R right away. This key combination tells your Mac to reinstall the
same version of macOS that was already installed. If you're hoping for a different version,
check out these alternatives:

To upgrade you macOS to the most current OS that is compatible with your Mac, press
Opt+⌘Cmd+ R. For example, a Mac from early 2012 will not be compatible with
macOS10.15, Catalina.
To install the macOS your Mac came with, no matter how out-dated,

press ⇧ Shift+⌥Opt+⌘Cmd+ R. If you didn't have 10.12.14, Sierra, this key combination will
not work.

If you've never installed 10.12.14 (Sierra), using ⌘ Cmd+ R will install the OS without tying it to
your Apple ID. Use this key combination to erase your drive before giving it to someone else.

10
STEP: 3

Release the keys when you see the Apple logo


. You might see a spinning globe or a prompt for you to enter a firmware password.

STEP: 4
Choose if you want to erase your disk. Be warned that this will erase your disk and
you will lose all information on your computer. You can also opt to "Restore from
Time Machine Backup" if you don't want to lose everything.

STEP: 5

Click to select Reinstall macOS. This will reinstall the macOS but will keep your files
and user settings intact.

11
STEP: 6
Click Continue. You will start the process of reinstalling macOS.

STEP: 7

Follow the on-screen instructions to install MacOS. This includes selecting where
to install the OS. Please do not put your Mac to sleep or close its lid during the
installation process. You might see your Mac restart a few times, show a blank
screen, and show a few progress bars, but that does not mean installation is done.

12
Practical No.: 4

Aim: Installation of Linix using Virtual Box.


Installation of Virtual Box
Step 1: Download Virtualbox: https://www.virtualbox.org/wiki/Downloads
Step 2: Install VirtualBox on Windows 7, 8, 8.1 & Windows 10
New welcome windows will open to the setup wizards. If you want to start the
installation process or click on Cancel to exit the wizard.

Click Next to continue

You can choose multiple features or you can start with default features.

 If you want to create a shortcut on the desktop, then check on create a shortcut on
the desktop option and click on Next to proceed.

13
Ignore the warning and Click on the “Yes” button to proceed for the next step.

Click the install button. The next pop up window of UAC (Microsoft User Account
Control) will appear, click yes to proceed)

14
You will have to install drivers in Virtual Box to interact with the host machine’s
hardware as displayed in the figure. Click the install button to continue.

After the installation completes, click the finish button.

Now the installation process of Virtual box has been completed. Start Oracle VM
Virtual Box after installation.

It is first to look below.

15
Download the Linix Iso
Next, you need to download the ISO file of the Linux distribution. You can get this
image from the official website of the Linux distribution you are trying to use.
Install Linux using VirtualBox

You have installed VirtualBox and you have downloaded the ISO for Linux. You are
now set to install Linux in VirtualBox.

Start VirtualBox, and click on the New symbol. Give the virtual OS a relevant name.

Allocate RAM to the virtual OS. My system has 8GB of RAM and I decided to
allocate 2GB of it. You can use more RAM if your system has enough extra.

Create a virtual disk. This serves as the hard disk of the virtual Linux system. It is
where the virtual system will store its files.

16
using the VDI file type here.

You can choose either the “Dynamically allocated” or the “Fixed size” option for
creating the virtual hard disk.

The recommended size is 10 GB. However, I suggest giving it more space if


possible. 15-20 GB is preferable

17
Once everything is in place, it’s time to boot that ISO and install Linux as a virtual
operating system.

If VirtualBox doesn’t detect the Linux ISO, browse to its location by clicking the
folder icon as shown in the picture below:

Soon you’ll find yourself inside Linux. You should be presented with the option to
install it.

18
Things from here are Ubuntu-specific. Other Linux distributions may have slightly
different looking steps, but it won’t be complicated at all.

You can skip to Continue.

Select ‘Erase disk and install Ubuntu’. Don’t worry. It won’t delete anything on your
Windows operating system. You are using the virtual disk space of 15-20GB that
we created in previous steps. It won’t impact the real operating system.

19
Just click on Continue.

Things are pretty straightforward from here.

Self explanatory.

Try to choose a password that you can remember. You can also reset the password
in Ubuntu if you forget it.

20
You are almost done. It may take 10-15 minutes to complete the installation.

Once the installation finishes, restart the virtual system.

If it gets stuck on the screen below, you may close the VirtualBox.

You are all set to use.

21
Practical No.: 5

Aim: Implementation of Linux Command.

File Commands
1.  ls  Directory listing

2.  ls -al  Formatted listing with hidden files

3.  ls -lt  Sorting the Formatted listing by time modification

4.  cd dir  Change directory to dir

5.  cd  Change to home directory

6.  pwd  Show current working directory

7.  mkdir dir  Creating a directory dir

8.  cat >file  Places the standard input into the file

9.  more file  Output the contents of the file

10.  head file  Output the first 10 lines of the file

11.  tail file  Output the last 10 lines of the file

12.  tail -f file  Output the contents of file as it grows,starting with the last 10
lines

13.  touch file  Create or update file

14.  rm file  Deleting the file

15.  rm -r dir  Deleting the directory

16.  rm -f file  Force to remove the file

17.  rm -rf dir  Force to remove the directory dir

18.  cp file1 Copy the contents of file1 to file2


file2 

19.  cp -r dir1 Copy dir1 to dir2;create dir2 if not present


dir2 

20.  mv file1 Rename or move file1 to file2,if file2 is an existing directory


file2 

22
21.  ln -s file Create symbolic link link to file
link 

Process management
1.  ps  To display the currently working processes

2.  top  Display all running process

3. kill pid Kill the process with given pid 

4.  killall Kill all the process named proc 


proc 

5.  pkill Will kill all processes matching the pattern 


pattern 

6.  bg  List stopped or background jobs,resume a stopped job in the


background  

7.  fg  Brings the most recent job to foreground

8.  fg n  Brings job n to the foreground 

File permission 

1.  chmod octal file  Change the permission of file to octal,which can be
found separately for user,group,world by adding, 
• 4-read(r) 
• 2-write(w) 
• 1-execute(x)

Searching
1.  grep pattern Search for pattern in file

2.  grep -r pattern Search recursively for pattern in dir


dir 

3.  command | Search pattern in the output of a command


grep 
pattern

4.  locate file  Find all instances of file

5.  find . -name Searches in the current directory (represented by a

23
filename  period) and below it, for files and directories with
names starting with filename 

6.  pgrep pattern  Searches for all the named processes , that matches
with the pattern and, by default, returns their ID

System Info
1.  date  Show the current date and time

2.  cal  Show this month's calender

3.  uptime  Show current uptime

4.  w  Display who is on line

5.  whoami  Who you are logged in as

6. finger user Display information about user 

7.  uname -a  Show kernel information

8.  cat Cpu information


/proc/cpuinfo 

9.  cat Memory information 


proc/meminfo 

10.  man command  Show the manual for command

11.  df  Show the disk usage

12.  du  Show directory space usage

13.  free  Show memory and swap usage

14.  whereis app  Show possible locations of app

15.  which app  Show which applications will be run by default

Compression
1.  tar cf file.tar file  Create tar named file.tar containing file

2.  tar xf file.tar  Extract the files from file.tar

3.  tar czf file.tar.gz Create a tar with Gzip compression


files 

4.  tar xzf file.tar.gz  Extract a tar using Gzip

24
5.  tar cjf Create tar with Bzip2 compression
file.tar.bz2 

6.  tar xjf Extract a tar using Bzip2


file.tar.bz2 

7.  gzip file  Compresses file and renames it to file.gz

8.  gzip -d file.gz  Decompresses file.gz back to file

Network
1.  ping host  Ping host and output results

2.  whois domain  Get whois information for domains

3.  dig domain  Get DNS information for domain

4.  dig -x host  Reverse lookup host

5.  wget file  Download file

6.  wget -c file  Continue a stopped download

Shortcuts
1.  ctrl+c  Halts the current command

2.  ctrl+z  Stops the current command, resume with fg in the


foreground or bg in the background

3.  ctrl+d  Logout the current session, similar to exit 

4.  ctrl+w  Erases one word in the current line

5.  ctrl+u  Erases the whole line

6.  ctrl+r  Type to bring up a recent command

7.  !!  Repeats the last command

8.  exit  Logout the current session

25
Practical No.: 6

Aim: Implementation of CPU scheduling algorithm - FCFS to find turnaround


time and waiting time. 

#include<iostream>
using namespace std;

int main()
{
int n,bt[20],wt[20],tat[20],avwt = 0, avtat = 0;
cout<<"Enter Total Number of Processor: ";
cin>>n;
cout<<endl<<"Enter Process Burst Time"<<endl;
for(int i=0;i<n;i++)
{
cout<<"Process["<<i+1<<"]: ";
cin>>bt[i];
}
wt[0]=0;
for(int i=1;i<n;i++)

26
{
wt[i]=0;
for(int j=0;j<i;j++)
wt[i]+= bt[j];
}
cout<<endl<<"Process\t Burst Time\t Watimg Time\t Turnarround
Time";
for(int i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
avwt+= wt[i];
avtat+= tat[i];

cout<<endl<<"Process["<<i+1<<"]"<<"\t"<<bt[i]<<"\t\t"<<wt[i]<<"\t\t"<<tat[i];
}
cout<<endl<<endl<<"Average Wating Time: "<<avwt;
cout<<endl<<"Average Turnaround Time: "<<avtat;
return 0;
}
Output:-

27
Practical No.: 7

Aim:  Implementation of CPU scheduling algorithm - SJF to find turnaround


time and waiting time.

#include<iostream>
using namespace std;
int main()
{
int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp;
float awt, atat;
cout<<"Enter number of process: ";
cin>>n;
cout<<endl<<"Enter Burst Time:"<<endl;
for(i=0;i<n;i++)
{
cout<<"p"<<i+1<<": ";
cin>>bt[i];
p[i]=i+1;
}

28
for(i=1;i<n;i++)
{
pos=i;
for(j=i+1;j<n;j++)
{
if(bt[j]<bt[pos])
pos=j;
}
temp=bt[i];
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
wt[0]=0;
for(i=0;i<n;i++)
{
wt[i]=0;
for(j=0;j<i;j++)

wt[i]+=bt[j];
total+=wt[i];

}
awt=(float)total/n;
total=0;
cout<<endl<<"Process\t Burst Time \t Waiting Time\tTurn Around Time";
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
total+=tat[i];

29
cout<<endl<<"p"<<p[i]<<"\t\t"<<bt[i]<<"\t\t"<<wt[i]<<"\t\t"<<tat[i];
}
atat=(float)total/n;
cout<<endl<<endl<<"Averge Waiting time= "<<awt;
cout<<endl<<"Average Turnaround Time= "<<atat;
return 0;
}

Output:-

30
Practical No.: 8

Aim: Implementation of CPU scheduling algorithm – Round Robin (pre-emptive) to


find  turnaround time and waiting time.

#include<iostream>
using namespace std;
struct process
{
int no;
int at,et,wt,tt;
int tet,t;
};
int main()
{
process p[99];
int i,j,k;
cout<<"Enter No. of Processes: ";
int np;
cin>>np;
for(i=0;i<np;i++)

31
{
cout<<endl<<"Enter Execution Time of Process "<<i+1<<": ";
cin>>p[i].et;
p[i].tet=p[i].et;
p[i].at=p[i].t=p[i].tt=p[i].wt=0;
p[i].no=i+1;

}
cout<<endl<<"Enter Time Quantum: ";
int q;
cin>>q;
cout<<endl<<"Enter Data: ";
cout<<endl<<"Process Execution Time";
for(i=0;i<np;i++)
{
cout<<endl<<p[i].no<<"\t"<<p[i].et;

}
int totaltime = 0;
for(i=0;i<np;i++){
totaltime+=p[i].et;
}
i=0;
k=0;
int rrg[99];
for(j=0;j<totaltime;j++)
{
if((k==0)&&(p[i].et!=0))
{
p[i].wt=j;
if((p[i].t!=0))
{

32
p[i].wt=q*p[i].t;
}
}
if((p[i].et!=0)&&(k!=q))
{
rrg[j]=p[i].no;
p[i].et+1;
k++;

}
else
{
if((k==q)&&(p[i].et!=0))
{
p[i].t+=1;
}
i=i+1;
if(i==np)
{
i=0;
}
k=0;
j=j+1;
}
}
int twt=0;
int ttt=0;
cout<<endl<<"\t\tResult of Round Robin"<<endl;
cout<<endl<<"Processes\tExecution Time\tWating Time\Turn Around Time";
for(i=0;i<np;i++)
{
p[i].tt=p[i].wt+p[i].tet;

33
ttt+=p[i].tt;
twt+=p[i].wt;
cout<<endl<<p[i].no<<"\t\t\t"<<p[i].tet<<"\t"<<p[i].wt<<"\t\t"<<p[i].tt;
}
cout<<endl<<"Average Waiting Time"<<(float)twt/np;
cout<<endl<<"Average Turn Around time: "<<(float)ttt/np;
return 0;
}
Output:-

Practical No.: 9

Aim: Implementation of CPU scheduling algorithm – Priority to find turnaround time


and waiting time.

#include<iostream>
using namespace std;
int main()
{
int bt[20], p[20], wt[20], tat[20], pr[20], i, j, n, total=0, pos, temp, avgwt, avgtat;
cout<<"Enter Total Number Of Process: ";

34
cin>>n;
cout<<endl<<"Enter Burst Time and Priority:"<<endl;
for(i=0;i<n;i++)
{
cout<<endl<<"P["<<i+1<<"]\n";
cout<<"Burst Time: ";
cin>>bt[i];
cout<<"Priority: ";
cin>>pr[i];
p[i]=i+1;
}
for(i=0;i<n;i++)
{

pos=i;
for(j=i;j<n;j++)
{
if(pr[j]<pr[pos])
pos=j;
}
temp=pr[i];
pr[i]=pr[pos];
pr[pos]=temp;

temp=pr[i];
bt[i]=bt[pos];
bt[pos]=temp;

temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}

35
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0;j<n;j++)
wt[i]+=bt[j];

total+=wt[i];
}
avgwt=total/n;
total=0;
cout<<endl<<"Process\t Burst Time \tWaiting Time\tTurn Around Time";
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i]; //calaulate turn around time
total+=tat[i];
cout<<endl<<"P["<<p[i]<<"]\t "<<bt[i]<<"\t\t "<<wt[i]<<"\t\t
"<<tat[i];
}
avgtat=total/n; //average turn around time
cout<<endl<<endl<<"Average Wating Time= "<<avgwt;
cout<<endl<<"Average Turn Around Time= "<<avgtat;
return (0);
}

Output:-

36
Practical No.: 10

Aim: Simulate the Bankers algorithm for deadlock avoidance and deadlock
prevention.

#include<iostream>
using namespace std;

#define MAX 20
class bankers
{
private:
int al[MAX][MAX],m[MAX][MAX],n[MAX][MAX],avail[MAX];
int nop,nor,k,result[MAX],pnum,work[MAX],finish[MAX];
public:
bankers();
void input();
void method();
int search(int);

37
void display();
};

bankers::bankers()
{
k=0;
for(int i=0;i<MAX;i++)
{
for(int j=0;j<MAX;j++)
{
al[i][j]=0;
m[i][j]=0;
n[i][j]=0;
}
avail[i]=0;
result[i]=0;
finish[i]=0;
}
}

void bankers::input()
{
int i,j;
cout<<"Enter the number of processes:";
cin>>nop;
cout<<"Enter the number of resources:";
cin>>nor;
cout<<"Enter the allocated resources for each process: "<<endl;
for(i=0;i<nop;i++)
{
cout<<"\nProcess "<<i;
for(j=0;j<nor;j++)

38
{
cout<<"\nResource "<<j<<":";
cin>>al[i][j];
}
}
cout<<"Enter the maximum resources that are needed for each process:
"<<endl;
for(i=0;i<nop;i++)
{
cout<<"\nProcess "<<i;
for(j=0;j<nor;j++)
{
cout<<"\nResouce "<<j<<":";
cin>>m[i][j];
n[i][j]=m[i][j]-al[i][j];
}
}
cout<<"Enter the currently available resources in the system: ";
for(j=0;j<nor;j++)
{
cout<<"Resource "<<j<<":";
cin>>avail[j];
work[j]=-1;
}
for(i=0;i<nop;i++)
finish[i]=0;
}

void bankers::method()
{
int i=0,j,flag;
while(1)

39
{
if(finish[i]==0)
{
pnum =search(i);
if(pnum!=-1)
{
result[k++]=i;
finish[i]=1;
for(j=0;j<nor;j++)
{
avail[j]=avail[j]+al[i][j];
}
}
}
i++;
if(i==nop)
{
flag=0;
for(j=0;j<nor;j++)
if(avail[j]!=work[j])
flag=1;
for(j=0;j<nor;j++)
work[j]=avail[j];
if(flag==0)
break;
else
i=0;
}
}
}

int bankers::search(int i)

40
{
int j;
for(j=0;j<nor;j++)
if(n[i][j]>avail[j])
return -1;
return 0;
}

void bankers::display()
{
int i,j;
cout<<endl<<"OUTPUT:";
cout<<endl<<"========";
cout<<endl<<"PROCESS\t ALLOTED\t MAXIMUM\t NEED";
for(i=0;i<nop;i++)
{
cout<<"\nP"<<i+1<<"\t ";
for(j=0;j<nor;j++)
{
cout<<al[i][j]<<" ";
}
cout<<"\t ";
for (j=0;j<nor;j++)
{
cout<<m[i][j]<<" ";
}
cout<<"\t";
for(j=0;j<nor;j++ )
{
cout<<n[i][j]<<" ";
}
}

41
cout<<"\nThe sequence of the safe processes are: \n";
for(i=0;i<k;i++)
{
int temp = result[i]+1 ;
cout<<"P"<<temp<<" ";
}
cout<<"\nThe sequence of unsafe processes are: \n";
int flg=0;
for (i=0;i<nop;i++)
{
if(finish[i]==0)
{
flg=1;
}
cout<<"P"<<i<<" ";
}
cout<<endl<<"RESULT:";
cout<<endl<<"=======";
if(flg==1)
cout<<endl<<"The system is not in safe state and deadlock may occur!!";
else
cout<<endl<<"The system is in safe state and deadlock will not occur!!";
}

int main()
{
cout<<" DEADLOCK BANKER’S ALGORITHM "<<endl;
bankers B;
B.input ( );
B.method ( );
B.display ( );
return 0;

42
}
Output:-

43
Practical No.: 11

Aim: Implementing Shell Programming.


a) To write a program to find whether a number is even or odd.
PROGRAM:
echo -n "Enter numnber : "
read n

rem=$(( $n % 2 ))

if [ $rem -eq 0 ]
then
echo "$n is even number"
else
echo "$n is odd number"
fi
Output:-

b) To Write a Program to Find Greatest In Three Numbers.


PROGRAM:
echo "enter three numbers"
read a b c
if [ $a -gt $b ] && [ $a -gt $c ]
then
echo "A is Greatest"
else if [ $b -gt $c ]

44
then
echo "B is Greatest"
else
echo "C is Greatest"
fi
fi

Output:-

c) To find a factorial of a number using shell script


PROGRAM:
echo "enter the number"
read n
fact=1
i=1
while [ $i -le $n ]
do
fact=`expr $i \* $fact`
i=`expr $i + 1`
done
echo "the factorial number of $ni is $fact

Output:-

45
d) To write a program to display the Fibonacci series.

PROGRAM:
echo " Enter the limit for FIBONNACI SERIES"
read lim
n1=0
n2=1
var=0
echo "FIBONACCI SERIES IS "
echo "$n1"
echo "$n2"
while [ $var -lt `expr $lim - 2` ]
do
n3=`expr $n1 + $n2 `
n1=`expr $n2 `
n2=`expr $n3 `
var=`expr $var + 1 `
echo "$n2"
done

Output:-

e) To write a program to print first 10 numbers using for loop.

PROGRAM:
echo “Display first 10 numbers”

46
for((i=1;i<=10;i++))
do
echo $i
done

Output:-

47

You might also like