getting errors, anyone tell me why?

#include <stdio.h>

int main()
{
int count = 2; //variable declaration and initialization

while (count > 0) //looping structure
{
printf("continue\n"); //output
count = 1 + 1; //increment
}

printf("stop/n"); //output

Return 0; //terminate program
}
First of all, please use code-tags, it makes code easier to read. :-)

The problem here is that you try to increment your counter variable, while you should decrement it, until count equals 0. Change it to this and it will work:

1
2
3
4
5
6
while (count > 0)
{
   count--;
   printf("continue\n");
   ....
}
Last edited on
Topic archived. No new replies allowed.