Home » C Programming » Loops » Question
  1. How many times the while loop in the following program will get executed if a short int is 2 byte wide?
    #include <stdio.h>
    int main ( )
    {
    int a = 1;
    while (a <= 255)
    {
    printf ("%c %d \n", a, a);
    a++;
    }
    return 0;
    }
    1. Infinite times
    2. 255 times
    3. 256 times
    4. Only once
    5. 254 times
Correct Option: B

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



Your comments will be displayed only after manual approval.