Question:

What would be the output after executionof the following programme?

by  |  earlier

0 LIKES UnLike

main( )

{

char ch='Q';

ch=(ch>='A'&&ch<='z')?(ch+32):ch;

ch=(ch>'a'&&ch<='z')?(ch-32):ch;

printf("%c",ch);

}

 Tags:

   Report

1 ANSWERS


  1. q

    &#039;Q&#039; has the ASCII value of 81 (decimal) and &#039;q&#039; 113

    81 + 32 = 113

    note that the &#039;z&#039; in the first conditional statement; &quot;ch=(ch&gt;=&#039;A&#039;&amp;&amp;ch&lt;=&#039;z&#039;) ? (ch+32) : ch;&quot; should probably be uppercase. As the program is written, if ch=lower case to start with the output would be still be lower case, the first conditional would add 32 that the second conditional would then subtract, but if the &#039;z&#039; was &#039;Z&#039; then the first conditional  would just assign ch to ch (leaving it unchanged) and then the second would subtract 32 converting to upper case.

    though I&#039;m not sure what this has to do with TiVo &amp; DVRs

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.