#include<stdio.h>
#include<string.h>
int main()
{
int dec[] = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
char *rom[]=
{"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
int givennumber,i;
char romannumber[500] = "";
printf("\nENTER A POSITIVE INTEGER NUMBER\n");
scanf("%d",&givennumber);
for(i = 0;i<13;i++)
{
while(givennumber >= dec[i])
{
givennumber = givennumber - dec[i];
strcat(romannumber,rom[i]);
}
}
printf("\nroman number is = %s\n",romannumber);
return 0;
}
No comments:
Post a Comment