1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vinil7 [7]
3 years ago
10

#include #include int main( ) { int value = 10; int pid; value += 5; pid = fork( ); if (pid > 0 ) { value += 20; } printf(val

ue); return 0; } Select all the values that may be printed on the screen when the above program is executed?
Computers and Technology
1 answer:
ss7ja [257]3 years ago
8 0

Explanation:

To understand how this program is working let us print the variable value at different stages of the program so that we can understand how it is working.

Intitally, value=10 when it was declared.

Then we added 5 and it become value=15

then we used fork() function which creates a parent(orignal) and child(duplicate)

When fork() succeeds it returns the child pid to parent and returns 0 to the child. As you can see (pid > 0) condition is always true therefore the parent pid value becomes 35 ( 15+20) and the child pid value becomes 0.

#include <stdio.h>

#include <unistd.h>

int main( ) {

   int value = 10;

     printf("%d\n",value);

   int pid;

   value += 5;

     printf("%d\n",value);

   pid = fork( );

     printf("%d\n",pid);

   if (pid > 0 )

   {

       value += 20;

   }

   printf("%d\n",value);

   return 0;

}

Output:

10 (initial value)

15 (modified value)

5343 (pid when fork is used)

35 (final modified value)

0 (child value)

15 (the parent value when fork was used)

You might be interested in
Where is the thesis statement usually located in research paper?
Ugo [173]
The thesis statement is typically located in the last sentence of the first paragraph of a research paper.
7 0
3 years ago
Write a script that calculates the common factors between 8 and 24. To find a common factor, you can use the modulo operator (%)
AnnyKZ [126]

Answer:

  1. common = []
  2. num1 = 8
  3. num2 = 24
  4. for i in range(1, num1 + 1):
  5.    if(num1 % i == 0 and num2 % i == 0):
  6.        common.append(i)
  7. print(common)

Explanation:

The solution is written in Python 3.

Firstly create a common list to hold a list of the common factor between 8 and 24 (Line 1).

Create two variables num1, and num2 and set 8 and 24 as their values, respectively (Line 3 - 4).

Create a for loop to traverse through the number from 1 to 8 and use modulus operator to check if num1 and num2 are divisible by current i value. If so the remainder of both num1%i and num2%i  will be zero and the if block will run to append the current i value to common list (Line 6-8).

After the loop, print the common list and we shall get [1, 2, 4, 8]

8 0
3 years ago
. Which of the following refers to the informal rules for how to behave online? A.
natta225 [31]

Answer:

D.netiquette

hope it is helpful to you

5 0
2 years ago
What is the quotient of 8.16 ÷ 100​
Natalka [10]

Answer:

0.0816

Explanation:

8.16 ÷ 100 = 0.0816 (Ans)

6 0
2 years ago
What three reasons does Dr. Boyd give to explain why returning to a friends only network would be impossible
Digiron [165]
Ummmmmm... Dr. Boyd is a Psychologist  that has nothing to do with computers and technology
7 0
3 years ago
Other questions:
  • What does the Flippy Do Pro show about representing very small numbers?
    13·1 answer
  • What is a way to Procter your social security number and other sensitive information from identity theft
    9·1 answer
  • This formatting option functions like a space bar. However, instead of moving one space at a time, it allows you to move your te
    6·1 answer
  • In an advanced word processing program which type of image or graphic is available in a variety of formats and styles?
    12·2 answers
  • An example of a current disruptive technology is a?
    8·2 answers
  • Which of the following best describes a group?
    13·1 answer
  • E-mail has made it very easy to send a message to more than one person at any time of day from just about anywhere. If you wante
    12·2 answers
  • (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)Ex:Davy's auto shop servicesOil chan
    9·1 answer
  • At each layer of the OSI model, data is appended to the original message and then sent on to the next lower layer. What is this
    10·1 answer
  • What is DMTS. Explain it​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!