Code:#include <stdio.h> int max(int arr[],int n) { int max=0; int t; for (t=1;t<=n;t++) { if (arr[t-1]==0) { if (t==1) return 0; // arr = {0} max = arr[t-2]; break; } max = arr[n-1]; // none of arr elements are 0 case } return max; } int main () { int arr[]={1,2,2,3,5,0,0,0}; int n = sizeof(arr)/sizeof(arr[0]); printf("%d\n", max(arr,n)); return 0; }