Posts

Program 27-40

Image
  PPS LAB RECORD PROGRAMS   1.      Write a C program that converts a string representing a number in Roman numeral form to decimal form. [Follow regular convention for Roman numbers, Read string – parse it to convert in to decimal] Eg: Input: XL output: 40 Ans: Program: Program to convert Roman numeral to Decimal number. // Program to convert Roman Numerals to Numbers #include<stdio.h> #include<string.h> int value(char); intromanToDecimal(char[]); // Driver Program int main(void) { charstr[10]; intnum; printf("Enter Roman Number:"); scanf("%s",str); num=romanToDecimal(str); printf("Integer form of Roman Numeral is: %d",num); return 0; } // This function returns value of a Roman symbol int value(char r) { if (r == 'I') return 1; if (r == 'V') return 5; if (r == 'X') return 10; if (r == 'L') return 50; if (r == 'C') return 100; if (r