Infinite Loop and Int value

Hi
I am learning C (procedural programming now a days) and i have a very basic question, hope i will get help from this forum
suppose i have a piece of code like this
1
2
3
int i;
for(i=1; i>=1; i++)
   cout<<i;


Tell me wether that loop run infinitly?
If yes then what happen when the loop reaches to the max number that int data type store that is 32767. i am talking about int range
Can any one help me to solve my confusion.
AN earliest responce in this regard is highly appreciable.
Thanks in advance to all the experts of this forum
Best Regards
Hi,
I think best way to see the result is to compile and run the program :):
But anyway you can make an infinite loop as
for(;;)
That will loop while i is greater or equal to 1 but when the maximum int value is reached, adding one to that, the resulting value will be wrapped to the minimum one and the loop will stop
The minimum value for signed types should be -(max+1) so in your case -32768
Last edited on
Thanks Bazzy for helping. your post have helped me to clear my confusion.
Last edited on
Topic archived. No new replies allowed.