Tuesday, January 24, 2023

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 1. Use of while loop.

PROGRAM:

echo "enter no. of elements:"
read n
a=0
while [ $a -ne $n ]
do
    echo $a
    ((a++))
done

OUTPUT:

[bgc@localhost ~]$ sh pc1.sh
enter no. of elements:
3
0
1
2
[bgc@localhost ~]$

No comments:

Post a Comment