Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1- you must ask 3 digit number 2. Your output must look like the output with the

ID: 3585354 • Letter: 1

Question

1- you must ask 3 digit number 2. Your output must look like the output with the correct corresponding Roman Numeral. 3 -please please write the program in the notepad in the PC, and I really I will appreciate that if you open the notepad and write the program , I don't want answers without that Thank you so much, Roman Numeral Generator Your programming assignment is to create a Roman Numeral generator. You must ask the user for a 3 digit number and then output the correct corresponding Roman Numeral. An example output would look like this: Enter a 3 digit number 214 215 as a Roman Numeral is: CCXIV

Explanation / Answer

#include<stdio.h>

typedef struct roman {
   int dec;
   char *rom;
}Roman;

Roman *romans;

void init() {
   romans = malloc(sizeof(Roman)*12);
   romans[0].dec = 1;
   romans[0].rom = "I";

   romans[1].dec = 4;
   romans[1].rom = "IV";

   romans[2].dec = 5;
   romans[2].rom = "V";

   romans[3].dec = 9;
   romans[3].rom = "IX";

   romans[4].dec = 10;
   romans[4].rom = "X";

   romans[5].dec = 40;
   romans[5].rom = "XL";

   romans[6].dec = 50;
   romans[6].rom = "L";

   romans[7].dec = 90;
   romans[7].rom = "XC";

   romans[8].dec = 100;
   romans[8].rom = "C";

   romans[9].dec = 400;
   romans[9].rom = "CD";

   romans[10].dec = 500;
   romans[10].rom = "D";

   romans[11].dec = 900;
   romans[11].rom = "CM";

}

int main() {
   int n;
   int i;
   init();
   do {
       printf("Enter a 3 digit number: ");
       scanf("%d",&n);
   }while ( n < 100 || n > 999);

   printf("%d as Roman Numeral is: ", (n+1));
   for ( i = 11; i >= 0; i--)
       if (romans[i].dec <= n) {
           printf("%s",romans[i].rom);
           n -= romans[i].dec;
           i++;
       }
   printf(" ");
}