fork download
  1. #include <stdio.h>
  2. #include <conio.h>
  3. main(){
  4. char roman[30];
  5. int deci=0;
  6. int length,i,d[30];
  7. printf("The Roman equivalent to decimal
  8. ");
  9. printf("Decimal:.........Roman
  10. ");
  11. printf("%5d............%3c
  12. ",1,'I');
  13. printf("%5d............%3c
  14. ",5,'V');
  15. printf("%5d............%3c
  16. ",10,'X');
  17. printf("%5d............%3c
  18. ",50,'L');
  19. printf("%5d............%3c
  20. ",100,'C');
  21. printf("%5d............%3c
  22. ",500,'D');
  23. printf("%5d............%3c
  24. ",1000,'M');
  25. printf("Enter a Roman numeral:");
  26. scanf("%s",roman);
  27. length=strlen(roman);
  28. for(i=0;i<length;i++){
  29. switch(roman[i]){
  30. case 'm':
  31. case 'M': d[i]=1000; break;
  32. case 'd':
  33. case 'D': d[i]= 500; break;
  34. case 'c':
  35. case 'C': d[i]= 100; break;
  36. case 'l':
  37. case 'L': d[i]= 50; break;
  38. case 'x':
  39. case 'X': d[i]= 10; break;;
  40. case 'v':
  41. case 'V': d[i]= 5; break;
  42. case 'i':
  43. case 'I': d[i]= 1;
  44. }
  45. }
  46. for(i=0;i<length;i++){
  47. if(i==length-1 || d[i]>=d[i+1])
  48. deci += d[i];
  49. else
  50. deci -= d[i];
  51. }
  52. printf("The Decimal equivalent of Roman numeral %s is %d", roman, deci);
  53. }
Success #stdin #stdout #stderr 0.02s 6884KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/mnvQyu/prog:53:0: Syntax error: end_of_file_in_quasi_quotation
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit