[Solved] Make loop stop by pressing dot


Running your code through the popular online c compiler here:

http://www.tutorialspoint.com/compile_c_online.php

Your code ran as expected. What happens when you type “.”?

EDIT: (Solution)

The problem was that when you input a negative number,

a="-"

which has an integer value greater than zero, hence not triggering the negative case.

The solution then, is to check for the negative sign:

if (a == '-') {...}

Also, note that the ‘.’ entered to terminate the loop is being counted as a positive number.

0

solved Make loop stop by pressing dot