What is the output of this program? [code] #! /usr/bin/awk -f BEGIN { a=6 do { print "123hoidap"

Giang Phạm

New member
What is the output of this program?
Code:
   #! /usr/bin/awk -f
   BEGIN {
       a=6
       do {
           print "123hoidap"
           a++
       } while (a<5)
   }
A. nothing will print
B. "123hoidap" will print 5 times
C. "123hoidap" will print 4 times
D. "123hoidap" will print only 1 time
 
Answer: d
Explanation: Even the condition is false of do-while loop, the body is executed once.
Output:
root@ubuntu:/home/123hoidap# ./test.awk
123hoidap
root@ubuntu:/home/123hoidap#
 

Tìm kiếm

Back
Top