Q:

how many times will an unsigned Char loop run

I'm a noob at C/C++ So excuse the simplicity of the question, but here goes
unsigned char i;
for (i=0; i<1000; ++i)
  if ((i%4) == 0)
    printf("hello\n");

how many times will the code print "hello". I say 63, but alas its not one of the options. Can someone provide an answer, but more importantly an explanation as to why

A:

Note: I am assuming 8 bit char types.
You will overflow when you perform ++i for i equal to 255. At that point the language standard decrees that i becomes 0, a phenomenon commonly known as wraparound.
So, you have an infinite loop, since i<1000 for all values of i.

A:

I would urge you to conduct an experiment by running the code. If that doesn't clear things up, try printing out the values of i for which the condition is true. If you then notice any anomalies in how the value of i changes, think about possible causes of that.

A:

Answer is Infinite time, range of unsigned character is between 0-255(1 byte) when it goes beyond 255 it will overflow and come back to 0 that mean it will never reach to 1000 ..hence infinite loop 

