Multiple choice

What will be the output of the above code?

i=5
while test $i != 0
do
echo "$i"
i=`expr $i - 1`
done

  1. 5 4 3 2 1

  2. 5 4 3 2 1 0

  3. 1 2 3 4 5

  4. 0 1 2 3 4

  5. 5

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The initial value of variable 'i' is 5. The while loop will continue as long as the value of the variable 'i' is not equal to 0. Value of 'i' will be decremented in each iteration. Therefore, the result will be 5 4 3 2 1.