you have used wrong int num of base values you have to find the number value then you can put char value I, II, IV, IX, X, XL, XC, CM, CD, M, and more roman symbols.
Here used while loop with num/decimal with repeat num until it is not null.
#Here used printf loop also not correct for a valuable value which is used in this programming like
printf("Enter FIRST roman number (Valid digits are I, V, X, L, C, D, M): \n");
scanf("%s",roman_Number);
while(roman_Number[i]){
While loop also not well performed the roman number[i],
and many more.
if(digit(roman_Number[i]) < 0){
printf("Invalid roman digit : %c",roman_Number[i]);
return 0;
#include<stdio.h>
#include<string.h>
int digit(char);
void decimal2roman(int num){
int decimal[] = {1000,900,500,400,100,90,50,40,10,9,5,4,1}; //base values
char *symbol[] = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}; //roman symbols
int i = 0;
while(num){ //repeat process until num is not 0
while(num/decimal[i]){ //first base value that divides num is largest base value
printf("%s",symbol[i]); //print roman symbol equivalent to largest base value
num -= decimal[i]; //subtract largest base value from num
}
i++; //move to next base value to divide num
}
}
int main(){
char roman_Number[1000];
int i=0;
long int number =0;
printf("Enter FIRST roman number (Valid digits are I, V, X, L, C, D, M): \n");
scanf("%s",roman_Number);
while(roman_Number[i]){
if(digit(roman_Number[i]) < 0){
printf("Invalid roman digit : %c",roman_Number[i]);
return 0;
}
return 0;
For more info visit here:-
http://www.traininginlucknow.in/best-c-language-training-in-Lucknow.html