Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

CMU Amazon Strategic Plan Essay

CMU Amazon Strategic Plan Essay

Description

Homework #4

The intention of this homework is to understand process creation and pipes in Linux and to practice programming in Linux. 

Problem Statement 

• D.R. Kaprekar’s Operation, a process named after Indian mathematician D.R. Kaprekar, is described as follows. 

• Given any three- or four-digit number where not all digits are the same, i.e., not 111, 8888, etc., 

1. Rearrange the digits of the number in descending and ascending orders in order to make the largest and smallest numbers out of those digits. For example, given 2418, the largest number using these four digits is 8421 and the smallest one is 1248. 

2. Subtract the smaller number from larger one. 

  • 3. Take the result from step 2. Go to step 1 and repeat the process until the result converges. 
  • • Given the number 5438, the Kaprekar’s process is: 
  • 8543-3458 = 5085 8550-558 = 7992 9972-2799 = 7173 7731 – 1377 = 6354 6543 – 3456 = 3087 8730-378 = 8352 8532-2358 = 6174 7641-1467 = 6174 
  • 7641-1467 = 6174 
  • …… (converged) 
  • • For any 3-digit number where not all digits are the same, the final result will be 495

Requirement 

• Write a C program using the fork() system call to create a child process that executes Kaprekar’s Operation for a 3-digt number. The child process is required to print out the intermediate results as shown in the example above. The input number should be provided from the command line. For consistency, use the number “123” as the testing input. 

• In addition, the child process should inform the parent process about the completion of the operation, i.e., when the operation converges to a fixed number. This is done by sending the final converged number to the parent process using an ordinary pipe (refer to figure 3.25-3.26 for pipe creation). Upon receiving the message from the child, the parent process is required to print out the message. Have the parent invoke the wait() call to wait for the child process to complete before exiting the program. 

Steps:

  • • Download the incomplete source file hw4.c. The incomplete code obtains the input number and assigns it to variable n

• Complete the code 

• Compile the C source file using gcc. This is similar to our preparation homework. 

• Take a screenshot of the program intermediate results and final output (see screenshot 1 below as a sample output). 

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: School Class Pro only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by School Class Pro are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. School Class Pro is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At School Class Pro, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.