Consider the following programmain(){unsigned int i=10;while(i>=0)  {   printf("%u",i)   i--;   }}How many times the loop will get executedA.10B.9C.11D. infinite

This question is related to TCS Interview

Showing Answers 1 - 13 of 13 Answers

nagesh k

  • Aug 18th, 2006
 

since U mentoned i as unsigned loop will be infinite so ans is D

  Was this answer useful?  Yes

satyanarayan nayak

  • Nov 29th, 2006
 

the loop will continue for infinite times

  Was this answer useful?  Yes

Asylzhan

  • Jan 2nd, 2018
 

Answer :
10 9 8 7 6 5 4 3 2 1 0 65535 65534...

Explanation:
Since i is an unsigned integer it can never become negative.
So the expression i-- >=0 will always be true, leading to an infinite loop.

  Was this answer useful?  Yes

Anjali Murkute

  • Jan 10th, 2020
 

Unsigned into range is 0-255 so, when i--; and the control reaches while (0>=0 ) conditions will remail true and after that it will again decrease value of zero and due to range it will rotate back to 255. So again 255>=0 ... And so on.. Loop will iterate infinite times.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions