Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8.4, Problem 8.3PP
Program Plan Intro
Given code:
//Include necessary header files
#include <stdio.h>
#include "csapp.h"
//Define a main function
int main()
{
//Check, fork() is equal to zero
if(fork()==0)
{
//True, Print a
printf("A\n");
//Flush the output buffer
fflush(stdout);
//Exit
exit(0);
}
//Otherwise
else
{
//Print b
printf("B\n");
//Flush the output buffer
fflush(stdout);
//Return status information
waitpid(-1,NULL,0);
}
//Print c
printf("C\n");
//Flush the output buffer
fflush(stdout);
//Exit
exit(0);
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(x-)
hkt 2
1
m
y =
e
1+
4m q
1 +
4m²q+
Write a Python code to plot a graph of y against x for the
given range oft values from 0 to 150. Let h = 6.2, m = 5.2,
q = 8.6, k = 3.9. Each plot for different t values should be on
the same page.
Please do problems 5,6,7,8,9
(a) Assume that five generation units with third order cost
function (F: (P) = A: P²³ + B; P; ² + C; P; +D;) are in the circuit.
Write a computer program using any arbitrary programming
language (MATLAB, C++, C#, Python,...) to calculate economic.
load dispatch (ELD) using first order gradient method.
Note that all parameters and variables should be defined
inside the
program (at first lines) such that units' characteristics
and demand can be changed easily. Neglect grid losses.
Chapter 8 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 8.2 - Prob. 8.1PPCh. 8.4 - Prob. 8.2PPCh. 8.4 - Prob. 8.3PPCh. 8.4 - Prob. 8.4PPCh. 8.4 - Practice Problem 8.5 (solution page 797) Write a...Ch. 8.4 - Practice Problem 8.6 (solution page 797) Write a...Ch. 8.5 - Practice Problem 8.7 (solution page 798) Write a...Ch. 8.5 - Prob. 8.8PPCh. 8 - Prob. 8.9HWCh. 8 - In this chapter, we have introduced some functions...
Ch. 8 - How many hello output lines does this program...Ch. 8 - How many "hello' output lines does this program...Ch. 8 - Prob. 8.13HWCh. 8 - How many hello output lines does this program...Ch. 8 - How many "hello lines does this program print?Ch. 8 - Prob. 8.16HWCh. 8 - Prob. 8.17HWCh. 8 - Consider the following program: Determine which of...Ch. 8 - How many lines of output does the following...Ch. 8 - Use execve to write a program called my1s whose...Ch. 8 - What are the possible output sequences from the...Ch. 8 - Write your own version of the Unix system function...Ch. 8 - One of your colleagues is thinking of using...Ch. 8 - Modify the program in Figure 8.18 so that the...Ch. 8 - Write a version of the fgets function, called...
Knowledge Booster
Similar questions
- 2. (a) In this problem consider Newton's method. Write a PYTHON function computing an approximation of the root p of the equation 0 using Newton's method. Specifically the code will compute the terms xn of the = f(x) sequence f(xn) f'(xn)' Xn+1 = Xn n = 0, 1, 2, ..., where xo is a given initial guess (or approximation) of the root p. For stopping criterion use the following: If |xn+1 − xn| ≤ TOL for the first time, then return xn+1 as approximation of the root p. Allow the code to do only NMAX iterations. At every step n, the code should print the values n, xn, f(xn) and n+1- xn. In case where the number of iterations reaches the maximum allowed number of iterations without satisfying the stopping criterion, then the code should print an error message, for example: "Failure: Algorithm fail to converge using only NMAX iterations".arrow_forwarduse c++.arrow_forwardPractice Problems (5) 1) Write a program to make a table of the physical properties for water in the range of temperatures from 273 to 323 K. The Density : The conductivity: K= 0.34 + 9.278 * 10* T The Specific heat: Cp= 0.015539 (T – 308.2)² + 4180.9 p= 1200.92 – 1.0056 T + 0.001084 Tarrow_forward
- Problem 19. Double numerical integration is the application twice of a numerical integration method for single integration, once for the y direc- tion and another for the x direction. Any numerical integration method for single integration can be applied to double integration. Write a C++ program that applies Simpson's 1/3 rule to find the double integral 1-CC %3D3 ry%3+exp(x/5) I sin(x +y)dy) dr. %3D Jy=In(x)arrow_forwardProblem #2: A number is divisible by 11 if the difference of the sum of its digits at odd places and the sum of ts digits at even places is either 0 or divisible by 11. For example, for 2547039: (Sum of digits at odd places) - (Sum of digits at even places) = (9 + 0 +4 + 2) - (3+7+5)=D0 So 2547039 is divisible by Il, But for 13165648: (Sum of digits at odd places)- (Sum of digits at even places) = (8+6+6 +3) - (4+5 +1+1)= 12 12 is not divisible by 11 so 13165648 is also not divisible by 11. Sample run: Total is: 12 13165648 is not divisible by 11.arrow_forward(Practice) Run Program 7.10 to determine the average and standard deviation of the following list of 15 grades: 68, 72, 78, 69, 85, 98, 95, 75, 77, 82, 84, 91, 89, 65, and 74.arrow_forward
- (c) An electronic rainfall depth measurement device is developed to collect the data from the past 7 days as shown in Table 1 to study the weather condition at UniMAP. Table 1 [Jadual 1] Location: UniMAP Day Rainfall Depth (mm) 5.9 1 2 6.7 3 2.4 7.8 5.2 4 5 1.8 7 3.5 (i) Write a program in C to receive the values of rainfall depth and display the number of days with light rain ( 7.6 mm) from the record in Table 1. (ii) Rewrite the program in (c)(i) to identify and display the day with the lowest value of rainfall depth, the day with the highest value of rainfall depth and the average value of rainfall depth for the past 7 days.arrow_forwardQuestion 2 Using the incomplete programming code given, complete the code using dynamic programming with memory function, to reproduce the results in the following Table 1. (C++) #include<iostream>using namespace std; // max knapsack capacity // *** WRITE YOUR CODE HERE ***// num of items // *** WRITE YOUR CODE HERE ***// weight of each item // *** WRITE YOUR CODE HERE ***// value of each item // *** WRITE YOUR CODE HERE ***// variable for dynamic programming matrix // *** WRITE YOUR CODE HERE *** //==========================================// Dynamic programming function: recursive// ========================================= // ALGORITHM F(i,j) // int value // if F[i,j] is not filled yet (-1): // (start with j = W, i = n) // if capacity j < current item's weight w[i]: // value = recall F(i-1, j) // else: // we can include current item,…arrow_forward1. (Shortest Path) Please find the shortest path between the blue triangle and red tri- angle as Figure 1. Please explain your approach and develop the computationally efficient algorithm to get the results. Can you obtain (or estimate) the time com- plexity and memory complexity of your algorithm? 麗arrow_forward
- Using C++ programmingarrow_forward(Python) Define a function calc_pyramid_volume() with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyramid with a rectangular base. calc_pyramid_volume() calls the given calc_base_area() function in the calculation.Relevant geometry equations:Volume = base area x height x 1/3(Watch out for integer division).Sample output with inputs: 4.5 2.1 3.0Volume for 4.5, 2.1, 3.0 is: 9.45arrow_forward(Use GNU Octave programming)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr