What is the output of this program? [code] #!/bin/bash a=10 b=$(( $a<0?10:$a<100 )) echo $b exit 0[/code]

What is the output of this program?
Code:
   #!/bin/bash
   a=10
   b=$(( $a<0?10:$a<100 ))
   echo $b
   exit 0
A. 10
B. 20
C. 1
D. 0
 
Answer: c
Explanation: Firstly the '$a<0' condition has been checked. Because it is false hence the right hand side condition of the colon :)) has been checked and this is true so program output is 1.
Output:
root@ubuntu:/home/123hoidap# ./test.sh
1
root@ubuntu:/home/123hoidap#
 

Tìm kiếm

Back
Top