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

Assignment Help:

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


Related Discussions:- C program to convert number to binary

Programing, #question. write a program number to alphabet in c++..

#question. write a program number to alphabet in c++..

C code for implementation on binary heap, what is binary heap ? what is the...

what is binary heap ? what is the c code for the implementation for the binary heap

Define variable declaration in c++, Variable Declaration This declarati...

Variable Declaration This declaration of variables in the C language is permitted only in the starting of their block, prior to executable program statements. In C++ declaratio

What is some instance of operator overloading?, A: Here are a few of the ma...

A: Here are a few of the many instance of operator overloading: myString + yourString may concatenate two std::string objects myDate++ may increment a Date object a * b may m

Define bitwise-and operator, Define Bitwise-AND Operator: &:? The bitwi...

Define Bitwise-AND Operator: &:? The bitwise-AND operator (&) compares every bit of its first operand to the corresponding bit of its second operand. If both bits are 1 the mat

Define meaning of call by reference - computer programming, Define the Mean...

Define the Meaning of Call by reference? In "call-by- reference", as an alternative of passing the value of a variable, the location number (or the address) of the variable is

Program that will recursively prompt for input from the user, BACKGROUND: F...

BACKGROUND: FILE SYSTEMS  In a computer, a file system (sometimes written filesystem) is the way in which files are named and where they are placed logically for storage and ret

C++ Program Please see where i do mistake, #include #include #include ...

#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

Decision control instruction, if age of ram,shayam and ajay are input throu...

if age of ram,shayam and ajay are input through keyboard,write a program to determine the youngest of the three.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd