some description of the most common loops:
FOR loop:
a FOR loop is used when you want to go from, lets say, number one
to ten. thus looping ten times, but it cant be used to see if number one
is equal to zero or not.
example:
Code:
int i;
for (i = 0; i < 10; i++)
{
printf("Hello, World!\n");
}
WHILE loop:
a common loop used for checking stuff, like if number one has been pressed
or not. its also the best to use for your problem. example:
Code:
int input;
while(input != 0)
{
input = getInt();
}
-------
Some final notes:
you can exit a loop by the break; command. example:
Code:
int i;
for (i = 0; i < 10; i++)
{
printf("Hello, World!\n");
if (i == 5)
{
break;
}
}
if you run the code, you will notice that it doesnt print hello,world ten
times anymore. i hoped this helped, if it didnt, feel free to ask.