Hi, I am trying to do a while loop that terminates the program when 99999 is entered but otherwise allows infinite integers to be entered. My problem is that when a negative number is entered it crashes and also when I enter a number it displays it twice. Any help would be much appreciated.
Code:Code:#include <stdio.h> #include <stdlib.h> main() { int number; printf("Input an integer.\n"); do { scanf("%d",&number); /* read a single integer value in */ printf("%d\n",number); } while (number != 99999); }