Awk Programming Question:

Download Job Interview Questions and Answers PDF

Define the output of the program?

#! /usr/bin/awk -f
BEGIN {
a["linux","MCQ"]="google"
print a["linux","MCQ"]
}
a) google
b) linux MCQ
c) a["linux","MCQ"]
d) syntax error

Awk Programming Interview Question
Awk Programming Interview Question

Answer:

a) google
Output:
root@ubuntu:/home/google# ./test.awk
google
root@ubuntu:/home/google#

Download Awk Programming Interview Questions And Answers PDF

Previous QuestionNext Question
What is the output of the program?

#! /usr/bin/awk -f
BEGIN {
a[1]="google"
a[2]="google"
for(i=1;i<3;i++) {
print a[i]
}
}
a) "google" will print 2 times
b) "google" will print 3 times
c) program will generate error becasue 2 array elements have the same value
d) program will generate syntax error
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