Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program that prompts the user for two numbers at runtime and multiplies them using a la russe multiplication. No input is
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started