Question: 3. What is the output of this program?<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"><ol><li class="li1"><pre class="de1"> <span class="co2">#include&lt;stdio.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;stdlib.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;string.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;sys/types.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;sys/ipc.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;sys/msg.h&gt;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1"> <span class="kw4">struct</span> data_st<span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">long</span> <span class="kw4">int</span> id<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">char</span> buff<span class="br0">[</span><span class="nu0">11</span><span class="br0">]</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span> m_id<span class="sy0">,</span>ret<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">struct</span> data_st data1<span class="sy0">,</span> data2<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> m_id <span class="sy0">=</span> msgget<span class="br0">(</span><span class="br0">(</span>key_t<span class="br0">)</span><span class="nu0">181</span><span class="sy0">,</span><span class="nu8">0666</span><span class="sy0">|</span>IPC_CREAT<span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">if</span><span class="br0">(</span>m_id <span class="sy0">==</span> <span class="sy0">-</span><span class="nu0">1</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">perror</span><span class="br0">(</span><span class="st0">"msgget"</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> data1.<span class="me1">id</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">strcpy</span><span class="br0">(</span>data1.<span class="me1">buff</span><span class="sy0">,</span><span class="st0">"Sanfoundry"</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> ret <span class="sy0">=</span> msgsnd<span class="br0">(</span>m_id<span class="sy0">,&amp;</span>data1<span class="sy0">,</span><span class="nu0">11</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">printf</span><span class="br0">(</span><span class="st0">"%d<span class="es1">\n</span>"</span><span class="sy0">,</span>ret<span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">if</span><span class="br0">(</span>msgrcv<span class="br0">(</span>m_id<span class="sy0">,&amp;</span>data2<span class="sy0">,</span><span class="nu0">11</span><span class="sy0">,</span><span class="nu0">1</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">)</span> <span class="sy0">==</span> <span class="sy0">-</span><span class="nu0">1</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">perror</span><span class="br0">(</span><span class="st0">"msgrcv"</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">if</span><span class="br0">(</span>msgctl<span class="br0">(</span>m_id<span class="sy0">,</span>IPC_RMID<span class="sy0">,</span><span class="nu0">0</span><span class="br0">)</span> <span class="sy0">!=</span> <span class="nu0">0</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">perror</span><span class="br0">(</span><span class="st0">"msgctl"</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">return</span> <span class="nu0">0</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li></ol></div></div></div></div></div></div>
Options:
0
1
-1
none of the mentioned
Answer: A