Now consider a function where we print the array contents in…