Output problem in C

One of my friend gave me this code to run it on my computer.
I couldn’t understand the output.
Here is the code:

#include<stdio.h>
void main()
{
int i;
int ar[]={1,2,3,4};
for(i=0;ar[i]!=NULL;i++);
printf("%d",i);
}
OUTPUT: 25

If I change the code to this, the output changes quite dramatically:

#include<stdio.h>
void main()
{
int i;
int ar[]={0,1,2,3,4}; //There is an extra element ‘0’ in the first position.
for(i=0;ar[i]!=NULL;i++);
printf("%d",i);
}
OUTPUT: 0
So, it looks like 0 here is considered as a NULL value, which is really weird.
Can you guys please help me understand the problem?

Reason is in your array none of the element has a NULL Value . So i will keep on increasing till it find a null value . in above case at memory address of 26*(size of int) + address of ar , there is a garbage NULL Value !! So loop will terminate there and it will print 25.
while in the second case as a[0] is 0. loop will terminate at i=0.
and it will be printed.

//