Thursday, May 1, 2008

Write a shell script to print odd numbers upto ‘n’.

echo “Enter Upper limit”

read n

$i=1

while [$i -lt $n]

do

echo $i

expr ‘$i=$i+2’

done

3 comments:

Anonymous said...

not working :(

Unknown said...

Echo $1
i=1
While [ $i -lt $1 ]
Do
Echo $i
i =`express $i + 2`
Done

This will work

Gulshan Theke valliyil said...

Echo $1
i=1
While [ $i -lt $1 ]
Do
Echo $i
i =`express $i + 2`
Done

This will work