fork download
  1. #include <stdio.h>
  2. #define CRT_SECURE_NO_WARNINGS
  3. int main()
  4.  
  5. {
  6. int p=0;
  7.  
  8. do
  9. {
  10. printf("Enter a number : ");
  11. scanf("%d ", &p);
  12.  
  13. if(0<=p && p<=9)
  14. {
  15. printf("The number you entered is %d\n", p);
  16. break;
  17. }
  18.  
  19. printf("Your number is not in the range 0 to 9! Try again.\n");
  20.  
  21. } while (p<0||p>9);
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 4260KB
stdin
100
200
300
1
stdout
Enter a number : Your number is not in the range 0 to 9! Try again.
Enter a number : Your number is not in the range 0 to 9! Try again.
Enter a number : Your number is not in the range 0 to 9! Try again.
Enter a number : The number you entered is 1