Multiple choice

Which of the following programs prints ABCDEFG?

  1. void main() { int i; for(i=65;i<=71;printf(%d,i),i++); }

  2. void main() { int i; for(i=65;i<=71;printf(%c,i)); }

  3. void main() { int i; for(i=65;i<=71;printf(%c,i),i++); }

  4. void main() { int i; for(i=65;i<=70;printf(%c,i),i++); }

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Loop will execute for i = 65 to 71. The ASCII value of 'A' = 65 and ASCII value of 'G' = 71 Hence, the output will be “ABCDEFG”.