Automata Questions – 6
Q6. Check for syntax error/ logical error and correct the error to get the desired output.
Given n, print from n to 0
unsigned int i = n;
while(i >= 0)
Output: Infinite loop
Answer: Error – Logical error
unsigned int i = n; unsigned integer ranges from 0 to 65535, which will be taken in the
cyclic order. So i– will keep repeating in a cyclic way. The loop will never be terminated.
So it should be written as int i = n;