Question 1949 – Nielit STA 17-12-2017
December 10, 2023Question 1966 – Nielit STA 17-12-2017
December 10, 2023Question 1957 – Nielit STA 17-12-2017
How many times the word “PROCESS” will be printed when executing the following program?
main()
{
printf(“process”);
fflush();
fork();
fork();
}
Correct Answer: B
Question 35 Explanation:
→ fflush() is typically used for output stream only. Its purpose is to clear (or flush) the output buffer and move the buffered data to console (in case of stdout) or disk (in case of file output stream).
→ The two fork() calls create 3 child processes, and hence “PROCESS” will be executed 4 times if we don’t use fflush.
→ If we put a ‘\n’ at end of printf or use fflush(stdout); only 1 printf will be done.
→ The two fork() calls create 3 child processes, and hence “PROCESS” will be executed 4 times if we don’t use fflush.
→ If we put a ‘\n’ at end of printf or use fflush(stdout); only 1 printf will be done.
8
4
6
7
Subscribe
Login
0 Comments