C Programming - Control Instructions - Discussion

Discussion Forum : Control Instructions - General Questions (Q.No. 2)
2.
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;
}
Infinite times
255 times
256 times
254 times
Answer: Option
Explanation:

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

Discussion:
59 comments Page 6 of 6.

Gowrishankar said:   1 decade ago
Thank you for discussion saswati and navana.

Pankaj said:   10 years ago
Its signed so how 255 could be the answer?

Sowjanya said:   10 years ago
Thank you all for your suggestions.

Eswari said:   1 decade ago
Thank you for swathi and karthi.

Vivek kkumar said:   1 decade ago
I could not understand.

Manoj said:   1 decade ago
Thank you karthi.

Mady said:   1 decade ago
Thank you swathi.

SATYA VAAG said:   1 decade ago
THANKS TO ALL

Arun said:   1 decade ago
Good answer.


Post your comments here:

Your comments will be displayed after verification.