if (number == 0)
{
cout << "Zero\n";
}
{
h = number/100;
number = number%100;
if (number>10 && number<20)
{
t = 0;
o = 0;
r = number%10;
}
}
else
{
t = number/10;
number = number%10;
o = number;
}
I tried doing what I can but it still says the error.
Yes, but there is another block separating that if from your else starting on line 6.
1 2 3 4 5 6
if{ //Start of if
}
{ //Start of another code block; indicates previous if statement is done
}
else{ //an else that is presumed to belong to a separate if-else statement
}
Either you're missing an elseif on line 6 or that code block is in the wrong place.
int main()
{
int number;
int h;
int o;
int r;
int t;
cout << "Enter a number: ";
cin >> number;
cout << "\nNumber: " << number;
cout << "Roman number: ";
if (number == 0)
{
cout << "Zero\n";
}
{
h = number/100;
number = number%100;
if (number>10 && number<20)
{
t = 0;
o = 0;
r = number%10;
}
}
else
{
t = number/10;
number = number%10;
o = number;
}
switch(h)
if (number == 0)
{
cout << "Zero\n";
}
else{ //This else will correspond to the if on line 13
h = number/100;
number = number%100;
if (number>10 && number<20)
{
t = 0;
o = 0;
r = number%10;
}
else{//This one will correspond to the if on line 22
t = number/10;
number = number%10;
o = number;
}
}
I'm not sure I understand why you have lines 22 to 27 (relative to my revision) in what appears to be a decimal to roman number conversion program. There is nothing special about roman numbers in the (10, 20) range.