Practice Problem 8.6 (solution page 797)
Write a
linux>./myecho arg1 arg2
Command-ine argument :
argv [0]: myecho
argv [1]: arg1
argv [2]: arg2
Environment variables
envp [0] : PWD = /usro/droh/1GB/code/ec1
envp [1] : TERM= emacs
.
.
.
envp [25] : USER = droh
envp [26] : SHELL = /usr/local/bin/tech
envp [27] : HOME -= usr0/droh
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Experiencing MIS
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with C++ from Control Structures to Objects (9th Edition)
- (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_forward35.3 Lecture 19-Apr-Q3 Suppose you are given a function in module foo named loop_string_reverse to reverse a string using loops that accepts the original string and returns the reversed string. But the numbers in the string are ignored. for eg, If the user input is he2ll8o will resolve to hello after removing the numbers 2 and 8 which will produce olleh as the reverse string output Now define a function loop_string_reverse_all that accepts a list of user entries and applies the method loop_string_reverse`` in modulefoo``` to each of them, and returns a new list of reverse strings. If function accepts the list input ['ab2ji89','6hel', 'ol5f'] then the function call returns the list ['ijba', 'leh ', 'flo'] Please answer in Python thank youarrow_forwardx=[10,1,20,3,6,2,5,11,15,2,12,14,17,18,29] for i in range(0, len(x)): m = x[i] l = i # Finding the minimum value and its location for j in range(i+1, len(x)): if(m >x [j]): m= x[j] l = j # Now we will do the swapping tmpry = m x[l] = x[i] x[i] = tmpry print(x) 8.The code above is written in Python programming language. In this sample, there are many sectors where you can apply knowledge of code refactoring. Mention each criteria where this code lacks and provide appropriate suggestions to improve. (Hint: Code Smells e.g: Naming Convention, Code length, Assertion etc.)arrow_forward
- (Practice) For the following function headers, determine the number, type, and order(sequence) of the values that must be passed to the function: a. void factorial(int n) b. void volts(int res, double induct, double cap) c. void power(int type, double induct, double cap) d. void flag(char type, double current, double time) e. void total(double amount, double rate) f. void roi(int a, int b, char c, char d, double e, double f) g. void getVal(int item, int iter, char decflag, char delim)arrow_forward4.6.1: Recursive function: Writing the base case. Add an if branch to complete double_pennies()'s base case.Sample output with inputs: 1 10Number of pennies after 10 days: 1024 Note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message # Returns number of pennies if pennies are doubled num_days timesdef double_pennies(num_pennies, num_days):total_pennies = 0 ''' Your solution goes here ''' else:total_pennies = double_pennies((num_pennies * 2), (num_days - 1)) return total_pennies # Program computes pennies if you have 1 penny today,# 2 pennies after one day, 4 after two days, and so onstarting_pennies = int(input())user_days = int(input()) print('Number of pennies after', user_days, 'days: ', end="")print(double_pennies(starting_pennies, user_days))arrow_forwardPlease solve and show steps, work, and information related to this problem. Thank you. The following C++ code performs a set of various arithmetic operations using both pointers and references: Fill in a memory table that shows the final values for both function a and function b. Indicate the final values of each parameter, passed in variable(s), and the return value of the function. Provide a separate copy of this memory table for each function.arrow_forward
- 2. (5.12 in 8e) answer each of the followig question. a) what does it mean to choose numbers "at random"? b) why is the rand function useful for simulating games of chance? c) why would you randomize a program by using srand? Under what circumstances is it desirable not to randomize? d) why is it often necessary to scale and/or shift the values produced by rand ?arrow_forwardConsider the below code: What would the output if dynamic scoping is used. Consider that execution of the code starts from main() function. #include <stdio.h> void main() { int x =3; A(x); B(x); C(x); } void A(int x) { printf("%d",x); } void B(int x) { int x =1; A(x); } void C(int x) { int x =2; B(x); }arrow_forward[8] A C program containing the function food has been compiled into LC-3 assembly language. The partial translation of the function is:food:ADD R6, R6, #2STR R7, R6, #0ADD R6, R6, #1STR R5, R6, #0 ADD R5, R6, #1 ADD R6, R6, #4...How many local variables does this function have?a. 3b. 4c. 5d. 6arrow_forward
- . You are given the following information. A function with prototype int mystery(int a, int b, int c, int d); is compiled into assembly code. The body of the code is as follows: leal (%rdi,%rsi,2), %eax leal (%rdx,%rdx,2), %edx addl %edx, %eax leal (%rax,%rcx,4), %eax ret Assume a at rdi, b at rsi, c at rdx, d at rcx, and the return value at eax. Write the C code for mystery function that will have an effect equivalent to the assembly code above. Please dont copy and paste.arrow_forward(Practice) a. Using Figure 2.14 and assuming the variable name rate is assigned to the byte at memory address 159, determine the addresses corresponding to each variable declared in the following statements. Also, fill in the correct number of bytes with the initialization data included in the declaration statements. (Use letters for the characters, not the computer codes that would actually be stored.) floatrate; charch1=M,ch2=E,ch3=L,ch4=T; doubletaxes; intnum,count=0; b. Repeat Exercise 9a, but substitute the actual byte patterns that a computer using the ASCII code would use to store characters in the variables ch1, ch2, ch3, and ch4. (Hint: Use Appendix B.)arrow_forwardThis problem is adapted from an earlier edition of P&H, and should be submitted.Consider the following code used to implement a new instruction: foo $t3,$t1,$t2:mask : . word 0xFFFFF83Fs t a r t : l a $t0 , masklw $t0 , 0 ( $ t 0 )l a $t3 , s h f t rlw $t3 , 0 ( $ t 3 )and $t3 , $t3 , $ t 0a ndi $t2 , $t2 , 0 x 0 0 1 fs l l $t2 , $t2 , 6o r $t3 , $t3 , $ t 2l a $t5 , s h f t rsw $t3 , 0 ( $ t 5 )s h f t r : s l l $t3 , $t1 , 0Add meaningful comments to the code and write a brief (2 sentence max) description of what foo does. Thisis not the same as saying how it does it - e.g., when asked to describe what a pedestrian is doing, you wouldsay they are walking, not that they are ilfting their left leg, angling it forward, putting it down, . . ..State at least one reason why writing “self-modifying code” such as this is a bad idea (and often times notactually allowed by the operating system)?arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning