Write a C program that prompts the user for two numbers at runtime and multiplies them...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C program that prompts the user for two numbers at runtime and multiplies them using "a la russe" multiplication. No input is allowed at execution time (no command line input). The numbers must be entered one at a time with an appropriate prompt from the program to instruct the user on what they should be doing. The program must display your banner logo from HW1 as part of a prompt to the user. The valid range of values for each number is 0 to 45000. You may assume that the user will always enter numerical decimal format characters at the keyboard. Your program should check this numerical range (including checking for negative numbers) and re-prompt the user for correct input if necessary. The program must also require the user to enter a single specific character of your choice to exit the program and return the main() function back to the terminal prompt. The program should print the result in decimal format and binary format. The binary output should use the least number of bits to display the number in multiples of 8 bits. I.e., anything less than 256 should display as 8 bits, anything less than 64k should use 16 bits, etc. . You may NOT use any libraries other than stdio.h and stdlib.h (no math.h) You may NOT use the multiplication operator or the division operator o Use bitwise shifting to halve and double numbers o Use modulus to detect if a value is even or odd There can be no "magic numbers" in the code o Any constants must be defined with a properly named #define macro You must use two source files and one header file o The header file must contain all MACRO's and function prototypes One source file must contain only the main() function, and any global variables. The other source file will contain all other functions as specified below The program must be built using the compile command like Tutorials Point (pdf p27-end of Chapter 8) You must have at least the following four functions in addition to main o o o o One function that prints your logo banner O One function that takes in a value and prints it in binary format One function that prompts the user for input and qualifies those values One function that takes in the two values, multiplies them, and returns the result Your program must keep the two input values and the result in global variables Your code should strive to adhere to the coding guidelines posted here: https://www.cs.swarthmore.edu/~newhall/unixhelp/c_codestyle.html Upload both source files and header file to Canvas assignment. Use one submission to upload all files. Do not zip the files together. Hint: You will need a while loop to process the values during the multiplication algorithm. Use printf() statements liberally throughout the code (especially within loops) to display data to the screen during execution for debugging purposes. Display all relevant values during the algorithm to analyze what is happening during your program. Use conditional compilation (#if) to control the printf() statements used for debugging. Write a C program that prompts the user for two numbers at runtime and multiplies them using "a la russe" multiplication. No input is allowed at execution time (no command line input). The numbers must be entered one at a time with an appropriate prompt from the program to instruct the user on what they should be doing. The program must display your banner logo from HW1 as part of a prompt to the user. The valid range of values for each number is 0 to 45000. You may assume that the user will always enter numerical decimal format characters at the keyboard. Your program should check this numerical range (including checking for negative numbers) and re-prompt the user for correct input if necessary. The program must also require the user to enter a single specific character of your choice to exit the program and return the main() function back to the terminal prompt. The program should print the result in decimal format and binary format. The binary output should use the least number of bits to display the number in multiples of 8 bits. I.e., anything less than 256 should display as 8 bits, anything less than 64k should use 16 bits, etc. . You may NOT use any libraries other than stdio.h and stdlib.h (no math.h) You may NOT use the multiplication operator or the division operator o Use bitwise shifting to halve and double numbers o Use modulus to detect if a value is even or odd There can be no "magic numbers" in the code o Any constants must be defined with a properly named #define macro You must use two source files and one header file o The header file must contain all MACRO's and function prototypes One source file must contain only the main() function, and any global variables. The other source file will contain all other functions as specified below The program must be built using the compile command like Tutorials Point (pdf p27-end of Chapter 8) You must have at least the following four functions in addition to main o o o o One function that prints your logo banner O One function that takes in a value and prints it in binary format One function that prompts the user for input and qualifies those values One function that takes in the two values, multiplies them, and returns the result Your program must keep the two input values and the result in global variables Your code should strive to adhere to the coding guidelines posted here: https://www.cs.swarthmore.edu/~newhall/unixhelp/c_codestyle.html Upload both source files and header file to Canvas assignment. Use one submission to upload all files. Do not zip the files together. Hint: You will need a while loop to process the values during the multiplication algorithm. Use printf() statements liberally throughout the code (especially within loops) to display data to the screen during execution for debugging purposes. Display all relevant values during the algorithm to analyze what is happening during your program. Use conditional compilation (#if) to control the printf() statements used for debugging.
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these computer network questions
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
: (i) What data structures are maintained by the page manager. (ii) What happens when a machine performs a read operation to a page. (iii) What happens when a machine performs a write operation to a...
-
Using algebra, find the slope and y-intercept of the line represented by each of the following equations. (a) 7x + 3y = 6 (b) 10y = 5x (c) (2y 3x)/2 = 4 (d) 1.8x + 0.3y 3 = 0 (e) 1/3x = -2 (f) 11x...
-
Briefly explain the standardisation/adaptation debate as applied to marketing communications. Explain, in broad terms, the strategic options available to marketers.
-
Malaria is spread by mosquitoes. That is, a mosquito spreads malaria by biting an infected person and later infusing malaria into a different person. A study by Jeffrey Sachs et al shows a strong...
-
Consider the discrete optimization problem The feasible set consists of a finite collection of m points in Rn, and we have one inequality constraint. Dualize the inequality and show that the dual...
-
Green Valley Company prepared the following trial balance at the end of its first year of operations ending December 31, 2014. To simplify the case, the amounts given are in thousands of dollars....
-
1. Evaluate the following using omega method in spherical coordinates 2. Compute dA/dt in each case ) A = sin, -r0 +rz; r = t,0 = 3t b) A = pp; p=t, = 2t,0 = 3t / / / / /
-
Your firm has decided to try two approaches to estimating a valuation allowance for sales returns. Required: a. First, your firm decides to estimate that 10% of all sales will eventually be returned....
-
know the following information about the Davis National Bank Total Interest Expenses ($500) Total Non Interest Income $100 Securities Gains (Losses) $ 50 Income Taxes ($ 80) Dividends to Stockholders...
-
What is a growing problem with the "Robin Hood" policy that dozens of school districts such as Plano ISD are facing in making recapture payments?
-
What is impact of income segregation? Explain briefly
-
The sales price of a product is $ 2 0 per unit; the variable cost is $ 5 per unit; and fixed costs total $ 1 , 5 0 0 . How many units must be sold to break even?
-
What is the Federal Reserve and who is the current Chair of the Fed? What are the discount rate and federal funds rate?
-
What is your current taxable income? What would your taxable income be in the new job? (B) How much of your salary increase will be paid in payroll taxes?
-
Q1: New World puzzle: There are four people who want to cross a rickety bridge; they all begin on the same side. You have 17 minutes to get them all across to the other side. It is night, and they...
-
What is the role of business risk analysis in the audit planning process?
-
Revise Listing 18.9 to develop a program that lets the user use the + and ? buttons to increase or decrease the current order by 1, as shown in Figure 18.12a. The initial order is 0. If the current...
-
In the nine tails problem, when you flip a coin, the horizontal and vertical neighboring cells are also flipped. Rewrite the program, assuming that all neighboring cells including the diagonal...
-
A palindromic prime is a prime number and also palindromic. For example, 131 is a prime and also a palindromic prime, as are 313 and 757. Write a program that displays the first 100 palindromic prime...
-
Consider a strictly risk averse agent endowed with initial wealth \(w_{0}\) and with a strictly increasing and twice differentiable utility function. Let \(r_{f}\) and \(\tilde{r}\) denote the return...
-
Consider a quadratic utility function \(u(x)=x-\frac{b}{2} x^{2}\), an initial wealth \(w_{0}=100\), a risk free rate \(r_{f}=1.1\) and a risky asset with expected return...
-
Consider the optimal portfolio choice problem in the presence of \(N\) risky assets with returns \(\left(\tilde{r}_{1}, \ldots, \tilde{r}_{N} ight)\) and of a risk free asset with return \(r_{f}>0\)....
Study smarter with the SolutionInn App