Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why an infinite loop

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
i have small program.i want to know why this goes into infinite loop?when i print value of i it gives 1 after certain iterations . is not 1 >-1 why then this infinite loop
main()
{
unsigned int i;
for(i=-10;i<=-1;i++)
printf(&quot;%d&quot;,i);
}
 
You have an UNSIGNED int and try to assign negative values to it and compare it with a negative value. Change the line &quot;unsigned int i;&quot; to &quot;int i;&quot;

Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top