Question: 9. What will be output for the given code?<div class="hk1_style-wrap4"><div class="hk1_style-wrap3"><div class="hk1_style-wrap2"><div class="hk1_style-wrap"><div class="hk1_style"><div class="c"><pre class="de1"><span class="co2">#include&lt;bits/stdc++.h&gt; </span> using namespace std<span class="sy0">;</span> string encrypter<span class="br0">(</span>string keyword<span class="br0">)</span> <span class="br0">{</span> string encoded <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> bool arr<span class="br0">[</span><span class="nu0">26</span><span class="br0">]</span> <span class="sy0">=</span> <span class="br0">{</span><span class="nu0">0</span><span class="br0">}</span><span class="sy0">;</span> <span class="kw1">for</span> <span class="br0">(</span><span class="kw4">int</span> i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i<span class="sy0">&lt;</span>keyword.<span class="me1">size</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw1">if</span><span class="br0">(</span>keyword<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&gt;=</span> <span class="st0">'A'</span> <span class="sy0">&amp;&amp;</span> keyword<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&lt;=</span> <span class="st0">'Z'</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw1">if</span> <span class="br0">(</span>arr<span class="br0">[</span>keyword<span class="br0">[</span>i<span class="br0">]</span><span class="sy0">-</span><span class="nu0">65</span><span class="br0">]</span> <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">)</span> <span class="br0">{</span> encoded <span class="sy0">+=</span> keyword<span class="br0">[</span>i<span class="br0">]</span><span class="sy0">;</span> arr<span class="br0">[</span>keyword<span class="br0">[</span>i<span class="br0">]</span><span class="sy0">-</span><span class="nu0">65</span><span class="br0">]</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="br0">}</span> <span class="br0">}</span> <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">(</span>keyword<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&gt;=</span> <span class="st0">'a'</span> <span class="sy0">&amp;&amp;</span> keyword<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&lt;=</span> <span class="st0">'z'</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw1">if</span> <span class="br0">(</span>arr<span class="br0">[</span>keyword<span class="br0">[</span>i<span class="br0">]</span><span class="sy0">-</span><span class="nu0">97</span><span class="br0">]</span> <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">)</span> <span class="br0">{</span> encoded <span class="sy0">+=</span> keyword<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">-</span> <span class="nu0">32</span><span class="sy0">;</span> alpha<span class="br0">[</span>keyword<span class="br0">[</span>i<span class="br0">]</span><span class="sy0">-</span><span class="nu0">97</span><span class="br0">]</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="br0">}</span> <span class="br0">}</span> <span class="br0">}</span> <span class="kw1">for</span> <span class="br0">(</span><span class="kw4">int</span> i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i<span class="sy0">&lt;</span><span class="nu0">26</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw1">if</span><span class="br0">(</span>arr<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">)</span> <span class="br0">{</span> arr<span class="br0">[</span>i<span class="br0">]</span><span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span> encoded <span class="sy0">+=</span> <span class="kw4">char</span><span class="br0">(</span>i <span class="sy0">+</span> <span class="nu0">65</span><span class="br0">)</span><span class="sy0">;</span> <span class="br0">}</span> <span class="br0">}</span> <span class="kw1">return</span> encoded<span class="sy0">;</span> <span class="br0">}</span> string ciphertxt<span class="br0">(</span>string msg<span class="sy0">,</span> string encoded<span class="br0">)</span> <span class="br0">{</span> string cipher<span class="sy0">=</span><span class="st0">""</span><span class="sy0">;</span> <span class="kw1">for</span> <span class="br0">(</span><span class="kw4">int</span> i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i<span class="sy0">&lt;</span>msg.<span class="me1">size</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw1">if</span> <span class="br0">(</span>msg<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&gt;=</span><span class="st0">'a'</span> <span class="sy0">&amp;&amp;</span> msg<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&lt;=</span><span class="st0">'z'</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw4">int</span> pos <span class="sy0">=</span> msg<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">-</span> <span class="nu0">97</span><span class="sy0">;</span> cipher <span class="sy0">+=</span> encoded<span class="br0">[</span>pos<span class="br0">]</span><span class="sy0">;</span> <span class="br0">}</span> <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">(</span>msg<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&gt;=</span><span class="st0">'A'</span> <span class="sy0">&amp;&amp;</span> msg<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">&lt;=</span><span class="st0">'Z'</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw4">int</span> pos <span class="sy0">=</span> msg<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">-</span> <span class="nu0">65</span><span class="sy0">;</span> cipher <span class="sy0">+=</span> encoded<span class="br0">[</span>pos<span class="br0">]</span><span class="sy0">;</span> <span class="br0">}</span> <span class="kw1">else</span> <span class="br0">{</span> cipher <span class="sy0">+=</span> msg<span class="br0">[</span>i<span class="br0">]</span><span class="sy0">;</span> <span class="br0">}</span> <span class="br0">}</span> <span class="kw1">return</span> cipher<span class="sy0">;</span> <span class="br0">}</span> <span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span> string keyword<span class="sy0">;</span> keyword <span class="sy0">=</span> <span class="st0">"cipher"</span><span class="sy0">;</span> string encoded <span class="sy0">=</span> encrypter<span class="br0">(</span>keyword<span class="br0">)</span><span class="sy0">;</span> string message <span class="sy0">=</span> <span class="st0">"hello"</span><span class="sy0">;</span> cout <span class="sy0">&lt;&lt;</span> ciphertxt<span class="br0">(</span>message<span class="sy0">,</span>encoded<span class="br0">)</span> <span class="sy0">&lt;&lt;</span> endl<span class="sy0">;</span> <span class="kw1">return</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="br0">}</span></pre></div></div></div></div></div></div>
Options:
bejjm
LFPDAR
BEJJM
lfpdar
Answer: C