/cs201-assignment2

conversion and add and multiplication in different formats(unary,binary,decimal,roman)

Primary LanguageC

cs201-assignment2

conversion and addition and multiplication in different formats(unary,binary,decimal,roman)

TWO INPUTS ARE TAKEN IN ANY OF THESE FORMATS(UNARY,BINARY,DECIMAL,ROMAN)AND THE RESULT OF ADDITION AND MULTIPLICATION OF THESE NUMBERS COMES AS AN OUTPUT IN THAT FORMAT ONLY

IN FIRST FUNCTION CONVERSION OF DECIMAL TO ROMAN IS DONE

Question OF Assignment 2

Since ancient times, the ability to represent numbers and perform arithmetic operations on numbers played an important role. Hence, it is interesting to study how different representation formats impact the number representation and operations. In this experiment, we study the efficacy of various number representation formats. The central message of this experiment is to appreciate that something that is as common as operating on numbers has an embedded data structure lesson. In this experiment, we will first understand how operations such as addition and multiplication can be done in various formats. We focus on four formats: unary, binary, decimal, and Roman. In each of these four representation formats, we will learn how to perform the above two operations. You can look at the lecture notes, browse through slides, and also see an animation that can run several examples.

  1. The Hindu/Arabic System : This is also known as the decimal system and is presently in vogue in written communication. The system used 10 digits 0, 1, 2, , 9. For instance three ⋯, 9. For instance three hundred and sixty seven is written as 367. This is a positional number system with the right most position having a weight of 1, the next position a weight of 10, and so on.
  2. The Roman System : This is a system using the symbols I, V, X, L, C, and M. This is not a positional system. As an example, 24 is written as XXIV.
  3. The Unary and the Binary System : In the former, the only symbol used is I and a number is represented by writing a number of I ́s equal to its value. For example, 7 is written as IIIIIII. It can be noticed that this system is too laborious for large numbers such as those beyond 20 or so.In the latter, two symbols 0 and 1 are used. This is a positional system with weights of 1, 2, 4, and so on. For instance, 55 is written as 110111. The latter is popular because of its use in the present generation computers.