#include
#include
#include
#include
void main()
{
clrscr();
int *a,l,i,j,k;
char *s;
printf("Enter The Roman Number
");
scanf("%s",s);
l=strlen(s);
for(i=0;i {
if(s[i]=='I')
a[i]=1;
else if(s[i]=='V')
a[i]=5;
else if(s[i]=='X')
a[i]=10;
else if(s[i]=='L')
a[i]=50;
else if(s[i]=='C')
a[i]=100;
else if(s[i]=='D')
a[i]=500;
else if(s[i]=='M')
a[i]=1000;
else
{
printf("Wrong Input");
getch();
exit(0);
}
}
k=a[l-1];
for(i=l-1;i>0;i--)
{
if(a[i]>a[i-1])
k=k-a[i-1];
else if(a[i]==a[i-1] || a[i]k=k+a[i-1];
}
printf("
%d",k);
getch();
}