C program to convert number to binary, C/C++ Programming

Write a program in C that you will name "divide.exe", to divide one 32-bit twos-complement binary number by another, giving the quotient and the remainder, using the subtract-shift division algorithm as demonstrated in class.

The program will be called using: div32 , where and are given as strings of up to 31 1's and 0's, with an optional sign. Your program must check that the input numbers are reasonable. The result must be output as binary numbers. Here are some example inputs and outputs:

> divide 1101011 1001

1101011 divided by 1001 is 1011 remainder 1000

> divide 107 9

107 is not a binary number

> divide -101001101 1100

101001101 divided by -1100 is -11011 remainder 1001

> divide 100010001000100010001000100010001 11101 0

100010001000100010001000100010001 is out of range

The exact error messages that need to be displayed are left to the discretion of the programmer. The inputs must be read in as text strings, and parsed and converted to appropriate long integers by your program. Similarly, the quotient and remainder must be converted and output as a sequence of 1's and 0's by your program.

Describe any limitations that may exist for your program. Full marks will only be given to programs capable of handling the complete range of inputs, however, a proper explanation of any limitations your program may have will minimize any deductions. Only properly commented code will receive full marks.

To test your code, select appropriate test cases to show that it works throughout the possible input range. Choosing a test set is a non-trivial problem and should be done with care, concentrating on number boundaries (maximum, minimum) and other code specific areas which may result in problems for your code. Include a printout of the results for all of your tests.

HINT: You may want to first implement an 8-bit version of your program, using signed chars rather than signed longs, and write a test program which checks it for all possible inputs. Once you are sure it works, you can convert it to the 32-bit version.

The "C" source code should contain a header which has the following information:

1.       Full name

2.       Student number

3.       Course number

4.       Date

Posted Date: 3/1/2013 12:39:44 AM | Location : United States

Related Discussions:- C program to convert number to binary, Assignment Help, Ask Question on C program to convert number to binary, Get Answer, Expert's Help, C program to convert number to binary Discussions

Write discussion on C program to convert number to binary
Your posts are moderated
Related Questions
Return by reference: The return value of the function must be an address variable.  In following program the function returns the value of x or y and their types are declare

Develop Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: C

Imagine that the server program is a setuid program owned by the root, then after you penetrate the program with a shell running, you become the ROOT and you can remove the whole f

C Program for FUNCTION OF FIND THE FACTORIAL float factorial(float); void main() {           float i=0,c=0;           clrscr();           printf("ENTER THE DIGI

A: Depends. Might be "zero" Objects which are thrown must have a publicly accessible copy-constructor. The compiler is permitted to generate code which copies the thrown object

Write a program called OddEven that will prompt the user for an integer and print/display a message indicating whether it is even or odd. Continue prompting for numbers from the us

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve betw   Solution:

Networking program development. 1.ARP protocol. 2.Switching HUB. 3.wireshark. 4.winpcap library. 5.C++ & MFC. 6.LAN evironment through switch and HUB(static ARP t

hi Bhasker, as we spoke tru phone ,we need a project using cloud computing .we need to present a protoype or demo on it (any thing using cloud should be fine)(ex: P2p)