SInce fork() is called, child processes are created and each process has its own data segment(static variables are in data segment), hence the answer is 10.
Even if the process uses copy on write the answer will be 10.
sakharam But here Z is declare as a static variable
as per my knowledge,
static variables and global variables are stored as same memory segment
if you are saying static variables are separate then global variable also separate
correct me if i am wrong.
No NO Shaik Masthan you're totally right
yes, even global variables are also separate
wow nice explanation sakharam Thanks