Awk Programming Question:
Download Questions PDF

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

Answer:

a) "google" will print 2 times
Output:
root@ubuntu:/home/google# ./test.awk
google
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["linux","MCQ"]="google"
print a["linux","MCQ"]
}
a) google
b) linux MCQ
c) a["linux","MCQ"]
d) syntax error
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