Some clarification first, when call fork it creates exact copy of the current program which runs on CPU independent of parent.
Both parent and child after the execution continues the execution from the same point, which is checking the value returned by the fork call. The only difference between the parent and the child will be the returned value of fork. For parent it will be the pid of the child (and not 0 as said in the question) and for child it will be 0.
Hence in this case, the if condition will evaluate TRUE for child, it will go inside the the if print the line Gate and then exit, the parent will see a non zero value, will print the 2016 and then exit. One thing to notice is that order of printing can differ as both parent and child are executing independent of each other (parent can issue a join call on the child as it knows the pid of child, which basically means that it will wait for the child to finish its operation).
In thie case, the output can be GATE2016 or 2016GATE or some garbled version of this, like GA20TE16.
However, if the code was like this:
int main(){
int pid = fork();
if(pid == 0){
printf("GATE");
exit(0);
}
join(pid); // not sure about the syntax
printf("2016");
}
Then the output will always be GATE2016.
Hope this helps.