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;
}
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 5 of 6.
Kanika joshi said:
1 decade ago
What happens if in the above question 'short int' is replaced by 'long int' ? Please help.
Sangeetha said:
1 decade ago
When this is short int. It again wrap around to zero so definitly infinite loop.
Mukesh Kumar said:
1 decade ago
What is the use of and meaning of "short int" here can anybody explain me?
Jaya said:
1 decade ago
In printf, why there are using %c. I can't understand please explain..
Ravitheja said:
1 decade ago
Thnks to all. Karthi please chek your values in this discussion.
Amandeep Kaur said:
1 decade ago
Answer is infinite times, how it will be execute 255 times?
Akash said:
1 decade ago
I can't understand because of %c and j two times print.
Amol wavare said:
10 years ago
Answer is finite times. How it will be 256>255?
Abhijeet Dhumal said:
3 years ago
Answer is 255.
I agree with the given answer.
I agree with the given answer.
(3)
Asha said:
1 decade ago
I can't understand using of %c please explain.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers