Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

EE1311 Homework 4 You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using

EE1311 Homework 4

You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using a la russe multiplication. The program must display your banner logo as part of the prompt to the user. The valid range of values is 0 to 4000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range and re-prompt the user for correct input if necessary. The program must also allow the user to enter a character to exit the program 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. The value 4000 times 4000 should only need 24 bits. You may NOT use any libraries other than stdio.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 You must use two source files o One source file will contain the main() function, global variables, and proper function prototypes. o The other source file will contain all other functions as specified below o 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 o One function that prints your logo banner o One function that takes in a value and prints it in binary format o One function that prompts the user for input and qualifies those values o 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 There can be no magic numbers in the code o Any constants must be defined with a Macro Your code should strive to adhere to the coding guidelines posted in the Guidelines section of the EE1311 Helpful Resources page (see Wiki)

Upload both source files together to the Blackboard assignment. Use one submission to upload both files. Do not zip the files together.

Hint: You will likely 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). Display all relevant values during the algorithm to analyze what is happening during your program. When the code is working, comment out the printf() statements, but do not erase them. Leave them there in case you want to enable them for further debugging later.

https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication#Russian_peasant_multiplication https://en.wikipedia.org/wiki/Bitwise_operations_in_C http://www.cprogramming.com/tutorial/bitwise_operators.html http://www.cprogramming.com/tutorial/modulus.html

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions