Asked inHP India,

main ( ) { unsigned int i=3; while( i >=0) printf( "%d", i--); } How many times will the printf stmt be executed? a) 0 b) 3 c) 4 d) infinite Ans: I think the answer is infinite, because 'i' is an unsigned integer and it will not decrement below '0' And hence end up in an infinite loop. (Yes, i checked and it is getting stuck in an infinite loop)

AnswerBot
1y

The printf statement will be executed 4 times.

  • The initial value of 'i' is 3.

  • In each iteration of the while loop, 'i' is decremented by 1.

  • The loop will continue until 'i' becomes less than 0.

  • Therefore,...read more

Help your peers!
Add answer anonymously...
HP India Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter