Computer Science: A Structured Programming Approach Using C, Third Edition
3rd Edition
ISBN: 9780534491321
Author: Behrouz A. Forouzan, Richard F. Gilberg
Publisher: Course Technology, Inc.
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 36PS
Program Plan Intro
To create a program by modifying the existing program, which is given in Program 4-5, to add the least significant 3 digit (hundreds, tens, ones).
Program Plan:
The program should be written in C
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
python cant be the same
Q2.
A. write a code to find the number of students who pass CS course, when their marks>=40 . As the list has 85 students. ( list must show how many students passed/failed) use htmp or py
B. wite a code to print this shape:
*
* *
* * *
* * * *
C. Write a code to find the area and parameter of a Tringle;
Area =1/2 * High * Base
Parameter= S1+S2+ Base
PYTHON QUESTION :
The Syracuse sequence of an integer N is the sequence of integers starting with the term N, where each following term is half of the preceding term if it is even, and one plus three times the preceding term if it is odd. The sequence ends when it reaches the integer 1.
The maximum of the Syracuse sequence of an integer N is the highest number reached by this sequence. This maximum can sometimes be very high compared to the starting integer N.
What is the maximum of the Syracuse sequence of 3428767?
To answer this question it is useful to modify the code given in demonstration which calculates the Syracuse sequence.
The code given in the demo :
n = 27
print(n)
while n != 1:
if n%2 == 0:
n = n // 2 # where n //= 2 or n >>= 1
else: n = 1 + 3*n
print(n)
Chapter 4 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
Ch. 4 - Prob. 1PSCh. 4 - The function definition contains the code for a...Ch. 4 - Function calls that return void may not be used as...Ch. 4 - The address operator (&) is used to tell the...Ch. 4 - Variables defined within a block have global...Ch. 4 - Prob. 6PSCh. 4 - Which of the following statements about function...Ch. 4 - Which of the following is not a part of a function...Ch. 4 - Which of the following statements about function...Ch. 4 - Which of the following statements about local...
Ch. 4 - Prob. 11PSCh. 4 - Prob. 12PSCh. 4 - Which of the following statements will generate a...Ch. 4 - Which of the following statements about structure...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function calls:...Ch. 4 - Evaluate the value of the following expressions:...Ch. 4 - Evaluate the value of the following...Ch. 4 - Prob. 23PSCh. 4 - Define the range of the random numbers generated...Ch. 4 - What would be printed from Program 4-17 when run...Ch. 4 - Prob. 26PSCh. 4 - Prob. 27PSCh. 4 - Prob. 28PSCh. 4 - Prob. 29PSCh. 4 - Write a program that generates a random number...Ch. 4 - Prob. 31PSCh. 4 - Code and run Program 4-16, "Top—down Development...Ch. 4 - Prob. 33PSCh. 4 - Prob. 34PSCh. 4 - Expand the calculator program, Program 4-15, to...Ch. 4 - Prob. 36PSCh. 4 - Write a function that receives a positive...Ch. 4 - Prob. 38PSCh. 4 - Prob. 39PSCh. 4 - Prepare a payroll earnings statement for the sales...Ch. 4 - Write a program that, given a beginning balance in...Ch. 4 - The formula for converting centigrade temperatures...Ch. 4 - Write a program that uses standard functions. The...Ch. 4 - Write a C program that creates customers' bills...
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
- 7. We usually write numbers in decimal form (or base 10), meaning numbers are composed using 10 different "digits" {0,1,.9). Sometimes though it is useful to write numbers in hexadecimal or base 16. Now there are 16 distinct digits that can be used to form numbers: {0,1,..,9,A,B,C,D,E,F}. So, for example, a 3 digit hexadecimal number might be 3B8. (a) How many 2-digit hexadecimals are there in which the first digit is E or F? Explain your answer in terms of the additive principle (using either events or sets). (b) Explain why your answer to the previous part is correct in terms of the multiplicative principle (using either events or sets). Why do both the additive and multiplicative principles give you the same answer? (c) How many 3-digit hexadecimals start with a letter (A-F) and end with a numeral (0-9)? Explain. (d) How many 3-digit hexadecimals start with a letter (A-F) or end with a numeral (0-9) (or both)? Explain.arrow_forward6. Write a program which reads string and rewrite it in alphabetical order. For example, the word STRING should be written as GINRST. 7. Write a program to replace a particular word by another word in a given string. For example the “PYTHON” should be replaced by “C” in the text “It is good to program in PYTHON language”. 8. Write a program that will find the maximum number from 3 float type numbers. You have to usethe function getMax which will take 3 pointer variables and return the maximum number.arrow_forwardii. Add a function named count_all() to this program that takes two parameters, a list of characters (e.g., x) and a character (e.g., y), in this order. This function must return the total number of times y appears in x. You must NOT use the built-in count() method to solve this problem.arrow_forward
- 09. Python Write the in_order() function, which has a list of integers as a parameter, and returns True if the integers are sorted (in order from low to high) or False otherwise. The program outputs "In order" if the list is sorted, or "Not in order" if the list is not sorted. Ex: If the list passed to the in_order() function is [5, 6, 7, 8, 3], then the function returns False and the program outputs: Not in order Ex: If the list passed to the in_order() function is [5, 6, 7, 8, 10], then the function returns True and the program outputs: In order Note: Use a for loop. DO NOT use sorted() or sort()..arrow_forwardprogram5_2.pyWrite another program that generates another table with the same columns and decimals but by using a function that returns the kilometers for a specified miles parameter. Use a loop in main and generate random integers as before, but catch the value returned by the function and use it in the loop to print a line of the table. Repeat: The table is printed in main.arrow_forwardPlease code in Java or C or C++ or C # or python 2 or 3 or R( Any one of the following)arrow_forward
- This code is for Pythonarrow_forwardonly code in c++ no outputarrow_forwardCODE USING C++ We've already tried comparing 3 numbers to see the largest among all, so let's try a more complicated mission where we locate where among the 5-digit integer is the largest one. There are only 4 possible cases for this mission: if the largest digit is the first digit, print "Leftmost" if the largest digit is the third digit, print "Middle" if the largest digit is the last digit, print "Rightmost" if none of the above is correct, print "Unknown" Now, show me how far you've understood your lessons! Input A line containing a five-digit integer. 14632 Output A line containing a string. Middlearrow_forward
- *Using Python The scientist has 500 cages in which to hold her rabbits. Each cage holds one pair of rabbits. Assuming that no rabbits ever die, when will she run out of cages? Your program must do the following: Print a table that contains the following information for each month. The number of months that have passed. The number adult rabbit pairs (those over 1 month old). The number of baby rabbits pairs produced this month. The total number of rabbit pairs in the lab. Calculate how many months it will take until the number of rabbits exceeds the number of available cages. Stop printing when you run out of cages. Print a message giving how many months it will take to run out of cages Output file should look like the following. Comments in the file begin with '#', and must appear as shown too: Code must contain def main(): #main function need in all programs for automated testing """ Program starts here """ #end of main program if __name__ == '__main__': main() #excucte main…arrow_forwarddef fun_a(cards): """ cards is a list of int numbers ranging between 0 to 12 inclusive. We use the number to represent the card's rank in a deck of card. 0 is '2', 1 is '3', ...,9 is 'J', 10 is 'Q', 11 is 'K' and 12 is 'A' This function is to check if there is four of a kind in the cards (4 cards of the same rank) and a fifth card as a kicker to form a four of a kind hands with 5 cards total. The 5 cards look like this: x x x x y (x might be the same as y). If there is more than one way to form such a hand with given cards, choose x that has the highest ranking (that has 4 cards of rank x), and choose y that has the highest ranking in the remaining cards after removing 4 x's. return (x, y) if such a hand exists. otherwise return None. """arrow_forward3. Write a function that uses regular expressions to extract SIN numbers with either dashes or spaces between the numbers, but not any other characters. E.g. the string 'My SINs are 123-456-798 and 987 654 321, and 987/432/321' should return the list ['123-456-798', '987 654 321']arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License