<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Roman Numerals Decoder Archives - Onestring Lab</title>
	<atom:link href="https://onestringlab.com/tag/roman-numerals-decoder/feed/" rel="self" type="application/rss+xml" />
	<link>https://onestringlab.com/tag/roman-numerals-decoder/</link>
	<description>Kode Kreativitas Kopi</description>
	<lastBuildDate>Mon, 04 May 2026 08:38:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://onestringlab.com/wp-content/uploads/2021/10/cropped-osl-high-res-e1455499003866-32x32.jpg</url>
	<title>Roman Numerals Decoder Archives - Onestring Lab</title>
	<link>https://onestringlab.com/tag/roman-numerals-decoder/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Belajar Bahasa C &#8211; Roman Numerals Decoder</title>
		<link>https://onestringlab.com/roman-numerals-decoder/</link>
		
		<dc:creator><![CDATA[Rajo Intan]]></dc:creator>
		<pubDate>Sun, 04 Dec 2022 03:24:06 +0000</pubDate>
				<category><![CDATA[Codewars]]></category>
		<category><![CDATA[C Language]]></category>
		<category><![CDATA[Roman Numerals Decoder]]></category>
		<guid isPermaLink="false">https://onestringlab.com/?p=805</guid>

					<description><![CDATA[<p>Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don&#8217;t need to validate &#8230; </p>
<p>The post <a href="https://onestringlab.com/roman-numerals-decoder/">Belajar Bahasa C &#8211; Roman Numerals Decoder</a> appeared first on <a href="https://onestringlab.com">Onestring Lab</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don&#8217;t need to validate the form of the Roman numeral.</p>



<p>Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost digit and skipping any 0s. So 1990 is rendered &#8220;MCMXC&#8221; (1000 = M, 900 = CM, 90 = XC) and 2008 is rendered &#8220;MMVIII&#8221; (2000 = MM, 8 = VIII). The Roman numeral for 1666, &#8220;MDCLXVI&#8221;, uses each letter in descending order.</p>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code class="">solution('XXI'); // should return 21</code></pre>



<p>The problem link is <a href="http://bit.ly/3Uv5guK" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p><strong>Solution:</strong></p>



<pre title="Roman Numerals Decoder" class="wp-block-code"><code lang="csharp" class="language-csharp line-numbers">#include &lt;string.h&gt;

int roman_val(char roman)
{
  int val = 0;

  switch (roman)
  {
  case 'I':
    return val = 1;
    break;
  case 'V':
    return val = 5;
    break;
  case 'X':
    return val = 10;
    break;
  case 'L':
    return val = 50;
    break;
  case 'C':
    return val = 100;
    break;
  case 'D':
    return val = 500;
    break;
  case 'M':
    return val = 1000;
    break;
  }
  return val;
}

unsigned decode_roman(const char *roman_number)
{
  unsigned long len = strlen(roman_number);
  unsigned i, n, m, value = 0;

  for (i = 0; i &lt; len; i++)
  {
    n = roman_val(roman_number[i]);
    m = roman_val(roman_number[i + 1]);

    if (n &gt;= m)
      value += n;
    else if (n &lt; m)
      value += (m - n), i++;
  }
  return value;
}
</code></pre>
<p>The post <a href="https://onestringlab.com/roman-numerals-decoder/">Belajar Bahasa C &#8211; Roman Numerals Decoder</a> appeared first on <a href="https://onestringlab.com">Onestring Lab</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
