@Ankit fork is a system call which generates new thread of execution,and returns pid of newly created thread to parent process and a value of 0 to child process.so here in second statement when fork is called 0 will be returned for child processes so they will not execute second fork in this call.so,doing in the same way you will get 20 as total no of processes created.
Given an integer n, write a function that returns count of trailing zeroes in n!. Examples: Input: n = 5 Output: 1 Factorial of 5 is 20 which has one trailing 0. Input: n = 20 Output: 4 Factorial of 20 is 2432902008176640000 which has 4 trailing zeroes. Input: n = 100 Output: 24
20
ReplyDelete@above you are right..:)
ReplyDelete@priyaranjan could you please explain the logic?
ReplyDelete@Ankit fork is a system call which generates new thread of execution,and returns pid of newly created thread to parent process and a value of 0 to child process.so here in second statement when fork is called 0 will be returned for child processes so they will not execute second fork in this call.so,doing in the same way you will get 20 as total no of processes created.
ReplyDeletehttp://www.csl.mtu.edu/cs4411/www/NOTES/process/fork/create.html
ReplyDelete