1. The command "awk '{if ("9″>"10″) print "google" else print "linux"}'"
a) will print "google"
b) will print "linux"
c) will generate syntax error
d) none of the mentioned

c) will generate syntax error
Explanation:
Semicolon is required just before the else statement to parse the statement.
Output:
root@ubuntu:/home/google# awk '{if ("9″>"10″) print "google" else print "linux"}'
awk: {if ("9″>"10″) print "google" else print "linux"}
awk: ^ syntax error
root@ubuntu:/home/google#

4. What is the output of this program?

#! /usr/bin/awk -f
BEGIN {
a=6
do {
print "google"
a++
} while (a<5)
}
a) nothing will print
b) "google" will print 5 times
c) "google" will print 4 times
d) "google" will print only 1 time

d) "google" will print only 1 time
Explanation:
Even the condition is false of do-while loop, the body is executed once.
Output:
root@ubuntu:/home/google# ./test.awk
google
root@ubuntu:/home/google#

5. What is the output of this program?

#! /usr/bin/awk -f
BEGIN {
a=5
while (a<5) {
print "google"
a++;
}
}
a) nothing will print
b) "google" will print 5 times
c) program will generate syntax error
d) none of the mentioned

a) nothing will print
Explanation:
The condition of while statement is false so commands inside the loop will not execute.
Output:
root@ubuntu:/home/google# ./test.awk
root@ubuntu:/home/google#

17. What is the output of the program?

#! /usr/bin/awk -f
#This filename is text.awk
BEGIN {
print FILENAME
}
a) test.awk
b) program will print nothing
c) syntax error
d) fatal error

b) program will print nothing
Explanation:
The built-in variable FILENAME is the name of file that awk is currently reading and in this program there is no file listed on the command line.
Output:
root@ubuntu:/home/google# ./test.awk
root@ubuntu:/home/google#

34. What is the output of this program?

#! /usr/bin/awk -f
BEGIN {
print "20"<"9" ? "true":"false"
}
a) true
b) false
c) syntax error
d) none of the mentioned

a) true
Explanation:
The operands of relational operators are converted to, and compared as string if both are not numbers. Strings are compared by comparing the characters of each. Hence 20 is less then 9.
Output:
root@ubuntu:/home/google# chmod +x test.awk
root@ubuntu:/home/google# ./test.awk
true
root@ubuntu:/home/google#