Write a general-purpose function to convert any given year into its roman equivalent. The following table shows the roman equivalents of decimal numbers.

Decimal

Roman

Decimal

Roman

Decimal

Roman

1

I

5

V

10

X

50

L

100

C

500

D

1000

M





Example:

Roman equivalent of 1988 is MDCCCCLXXXVIII

 Roman equivalent of 1525 is MDXXV.


source file name: RomanFun.C
#include <stdio.h>

void roman(int n, char ch) { int i; for( i=1;i<=n;i++) printf("%c ",ch); } int main() { int th=0,fh=0,h=0,ft=0,ten=0,fv=0,s=0; int n; //clrscr(); printf("\n enter any no: "); scanf("%d",&n); th=n/1000; roman(th,'M'); n=n%1000; fh=n/500; roman(fh,'D'); n=n%500; h=n/100; roman(h,'C'); n=n%100; ft=n/50; roman(ft,'L'); n=n%50; ten=n/10; roman(ten,'X'); n=n%10; fv=n/5; roman(fv,'V'); n=n%5; s=n; roman(s,'I'); //getch();
return 0; }

output: