echo “Enter upper limit”
read n
$i=2
while [$i -lt $n]
do
expr ‘$sum=$sum+$i’
expr ‘$i=$i+2’
done
echo “Sum is : $sum”
echo “Enter upper limit”
read n
$i=2
while [$i -lt $n]
do
expr ‘$sum=$sum+$i’
expr ‘$i=$i+2’
done
echo “Sum is : $sum”
3 comments:
Found many errors in your program. This works fine:
#! /bin/bash
echo enter limit
read n
i=2
while [ $i -lt $n ]
do
sum=$((sum+i))
i=$((i+2))
done
echo $sum.
Thanks.
thank you so much!!
thanks.....
Post a Comment