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
Concept explainers
Textbook Question
Chapter 8, Problem 8.18HW
Consider the following
Determine which of the following outputs are possible. Note; The atexit function takes a pointer to a function and adds it to a list of functions (initially empty) that will be called when the exit function is called.
- A. 112002
- B. 211020
- C. 102120
- D. 122001
- E. 100212
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
//-In python-//
def compute_stats():"""Write a function compute_stats, such that given a string of grades as an input parameter,it calls the function get_new_grades (defined in theprevious question) and returns a tuple that containsthe average value of the initial grades andthe average value after running the get_new_grades function.""" pass
The code should aslo have if __name__ == "__main__" section.
Write and test the “digit” function:
Function Prototype: int digit(int n,int k)This function returns the kth digit of the positive integer n. For example, if n is the integer 29,415 that is entered by user , then the call digit(n,0) would return the digit 2, and the call digit(n,2) would returnthe digit 4. do this only by using functions and loops. arrays are not allowed.
example :Input: n = 29415 , k = 1 output: 9
Input: n = 2 , k = 1 output: index out of bound (return -1)
1. Square Flower
You can have the turtle draw an interesting flower like sha pe by drawing n squares.
Each n-square flower is drawn after turning the turtle by some number of degrees
between each square. (see Figure 1 for an example)
(a) Typel: A 5-square red flower.
(b) A 15-square blue flower.
Figure 1: Two types of n-square flowers
Using the following implementation of draw square() function write a function
na med draw flower() that takes a turtle, the number n of squares to draw, the
side length and a color as parameters and draws an n-square flower by repeating the
function draw square() n times. Test your code by drawing a yellow 21-square
flower with side length of 200.
def drav aqu ar e (aTurtle, sidelength):
f or i in range (4) :
aTurtle.forvard (side Length)
aTurtle. 1eft (90)
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is denormalization?
Database Concepts (7th Edition)
For each of the following E-R diagrams from Chapter 2 C: Transform the diagram to a relational schema that show...
Modern Database Management (12th Edition)
A program has a float variable named total and a double variable named number. Write a statement that assigns n...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Open the Chap3\ Error2\ Error2 project from the student sample programs folder. The application has an error. F...
Starting Out With Visual Basic (8th Edition)
This characteristic of object-oriented programming allows the correct version of an overridden method to be cal...
Starting Out with Python (4th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Numerical) a. The following is an extremely useful programming algorithm for rounding a real number to n decimal places: Step 1: Multiply the number by 10n Step 2: Add 0.5 Step 3: Delete the fractional part of the result Step 4: Divide by 10n For example, using this algorithm to round the number 78.374625 to three decimal places yields: Step1:78.374625103=78374.625 Step2:78374.625+0.5=78375.125 Step3:Retainingtheintegerpart=78375Step4:78375dividedby103=78.375 Using this algorithm, write a C++ function that accepts a user-entered value and returns the result rounded to two decimal places. b. Enter, compile, and run the program written for Exercise 11a.arrow_forwardWrite and test the “digit” function:Function Prototype: int digit(int n,int k)This function returns the kth digit of the positive integer n. For example, if n is the integer 29,415, then the call digit(n,0) would return the digit 2, and the call digit(n,2) would return the digit 4.arrow_forwardThe following function uses reference variables as parameters. Rewrite the function so it uses pointers instead of reference variables, and then demonstrate the function in a complete program.int doSomething(int &x, int &y){int temp = x;x = y * 10;y = temp * 10;return x + y;}For example: if x = 5, y = 10 then the output should look like the following.arrow_forward
- ***in python only*** use turtle function Define the concentricCircles function such that: It draws a series of concentric circles, where the first parameter specifies the radius of the outermost circle, and the second parameter specifies the number of circles to draw. The third and fourth parameters specify an outer color and an other color, respectively. The outer color is used for the largest (i.e., outermost) circle, and then every other circle out to the edge alternates between that color and the 'other' color. The difference between the radii of subsequent circles is always the same, and this difference is also equal to the radius of the smallest circle. Put another way: the distance between the inside and outside of each ring is the same. Define concentricCircles with 4 parameters Use def to define concentricCircles with 4 parameters Use any kind of loop Within the definition of concentricCircles with 4 parameters, use any kind of loop in at least one place. Call…arrow_forwardVowel Words – a vowel word is a word that contains every vowel. Some examples of vowel words are sequoia, facetious, and dialogue. Write a program that uses a Boolean-valued function to determine whether a word input by the user is a vowel word. a) Request a word, word from the console.b) Define a function, isVowelWord(word) examines the word for vowels one at a time and terminates when a vowel is found to be missingor after all vowels have been considered. (Hint: Use in operator to check if a vowel appears in the word).c) Print out the search result (print statement should not be part of the function, isVowelWord(word)). Output Example 1:Enter a word: Education‘Education’ contains every vowel. Output Example 2:Enter a word: Python ‘Python’ does not contain every vowel. need help with pythonarrow_forwardMind tap Exercise 23 Write the definition of a void function that takes as input an integer and outputs two times the number if it is even; otherwise it outputs five times the number.arrow_forward
- -Write a function: int calculate(int x); * function returnsarrow_forwardVowel Words – a vowel word is a word that contains every vowel. Some examples of vowel words are sequoia, facetious, and dialogue. Write a program uses a Boolean-valued function to determine whether a word input by the user is a vowel word.a) Request a word, word from the console. b) Define a function, isVowelWord(word) examines the word for vowels one at a time and terminates when a vowel is found to be missing or after all vowels have been considered.(Hint: Use in operator to check if a vowel appears in the word)c) Print out the search result (print statement should not be part of the function, isVowelWord(word)).arrow_forwardAssignment Write a program to calculate n! for a given number n and perform the simple calculator operations. The valid operations of the calculator are: + add - sub * mul I div The program must contain a function fact with one input parameter that returns the factorial of a number, a function add that performs the addition of two numbers, a function sub that performs the subtraction of two numbers, a function mul that performs the multiplication of two numbers, a function div that performs the division of two numbers. The program must also check for bad input data. Make sure when you pass parameters you pass the addresses (not the value). • All function return type must be of type void. • Take inputs in main function. • Pass the addresses of the operands and the address of the result to each function. Output must be displayed as follows: 1: Addition 2: Subtraction 3: Multiplication 4: Division 5: Factorial 6: Quit Enter the choice => 1 Enter two numbers => 2, 3 Sum => 5arrow_forward
- C Program Functions using Pointers Create a function modify that accepts an integer and divides the integer by 2 if it is even. If the integer is odd, add one and divide it by 2. The function does not return anything. In the main function, write a program that asks for an integer input and call the modify function by passing in the reference of that variable as a parameter. An initial code is provided for you. Just fill in the blanks. Input 1. One line containing an integer input Output Enter a number: 5 Before: 5 After: 3arrow_forward// In python // def compute_stats():"""Write a function compute_stats, such that given a string of grades as an input parameter,it calls the function get_new_grades (defined in theprevious question) and returns a tuple that containsthe average value of the initial grades andthe average value after running the get_new_grades function.""" passarrow_forwardDefine stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name)" followed by a newline, and should return -1. Each stub must also contain the function's parameters. Sample output with two calls to get_user_num() and one call to compute_avg(): FIXME: Finish get_user_num() | FIXME: Finish get_user_num() FIXME: Finish compute_avg() Avg: -1 354684.2266598.qx3zgy7 2 Your solution goes here ''' 4 user_num1 5 user_num2 6 avg_result get_user_num() get_user_num) compute_avg(user_num1, user_num2) 8 user_num1 9 user_num2 10 avg_result %3D 11 12 print('Avg:', avg_result)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
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY