Thursday, May 1, 2008

Write a shell script to print natural numbers up to ‘n’ using while loop.

echo “Upper limit”
read n
$i = 1
while [$i -lt $n]
do
echo $i
expr ‘$i=$i+1’

done

3 comments:

Anonymous said...

your code has errors
this is the correct one

echo "enter value of n"
read n
echo "natural numbers:"
i=1
while [ $i -le $n ]
do
echo $i
i=`expr $i + 1`
done

Unknown said...

Kya re bhen k laude output nhi arha

Unknown said...

Your code also have errors