MCQ Single Best Answer Not Set

Q

How many times the while loop will get executed if a short int is 2 byte wide?

 
#include<stdio.h>
int main()
{
    int j=1;
    while(j <= 255)
    {
        printf("%c %d\n", j, j);
        j++;
    }
    return 0;
}

ID: #1370 C Language Loop Control 9,200 views
Question Info
#1370Q ID
Not SetDifficulty
C Language Loop ControlTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Infinite times
  • B 255 times
  • C 256 times
  • D 254 times
Correct Answer: Option A

Explanation

Option B
The while(j <= 255) loop will get executed 255 times. The size short int(2 byte wide) does not affect the while() loop.

Share This Question

Challenge a friend or share with your study group.