Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. while (1) { /*Loop*/
  2. if ((scanf("%d",&num)) != 1) { /* If the input is not valid, raise an error flag */
  3. return -1;
  4. } /* If the input is valid and in range, return it to the calling function */
  5. if (num >= n1 && num <= n2)
  6. return num;
  7. else /* If the input is valid but not in range, try again... */
  8. printf("The number must be between %d-%d. Try again: ",n1,n2);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement