Question: Pseudo roman numbers. Description: Write two C functions called extractDimDigit and printPseudoRomanString as a first step in converting integers from Arabic numerals (e.g., 17) to

Pseudo roman numbers.

Description:

Write two C functions called extractDimDigit and printPseudoRomanString as a first step in converting integers from Arabic numerals (e.g., 17) to Roman numerals (e.g., XIIIIIII).

For the purpose of this assignment, the definition of Roman numerals will be equivalent to the Wikipedia article on Roman numerals (http://en.wikipedia.org/wiki/Roman_numerals). Note that your program is not required to use the subtractive notation described in the article (so, for example, the number 4 will be represented by "IIII", not "IV"). Note you only have to consider numbers in the range from 1 to 4999. MMMMDCCCCLXXXXVIII represents 4999.

-----------------------------------------------

Input

The input is an integer number in the range from 1 to 4999, inclusive.

Output

Your program must output 4 lines. Each line must follow the format %d_%4d_%d_%s. The first column is the number to be processed. The second column is the number to be extracted (i.e., thousand, hundred, ten and one digit in a fourdigit number). The third column represents the digit extracted. The fourth column represents the number of thousands, hundreds, ten and ones in the corresponding Roman numeral (i.e., M, C, X, and I). Note the Roman numerals D, L, and V are NOT required.

------------------------------------------------------------------------------------------------------------------

Sample Input 1 :

4925

Sample Output 1:

4925_1000_4_MMMM 4925_ 100_9_CCCCCCCCC 4925_ 10_2_XX 4925_ 1_5_IIIII

----------------------------------------------------------------------------------------------

CODE FORM:

#include  #include  int extractDimDigit(int r, int dim) { // r is an integer in the range 1 to 4999 // dim is the dimension (i.e., 1000, 100, 10, 1) // this function returns one digit in the range 0 to 9 // replace with your code }//extractDimDigit void printPseudoRomanString(int d, int dim){ // this function prints a pseudo Roman numeral // that is, XIIIIIII instead of XVII for 17 // d is the number of letters to be output (i.e., M, C, X, or I) // depending on dim, the dimension (i.e., 1000, 100, 10, 1) // replace with your code }// printPseudoRomanString int main(void) { int r = 4925; // Try different values here to test your program int dim = 1000; int d = 0; for (int k = 0; k<4; k++) { d = extractDimDigit(r, dim); printf("%d_%4d_%d_", r, dim, d); printPseudoRomanString (d, dim); dim = dim /10; }//for return EXIT_SUCCESS; }//main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!