Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (1) { /*Loop*/
- if ((scanf("%d",&num)) != 1) { /* If the input is not valid, raise an error flag */
- return -1;
- } /* If the input is valid and in range, return it to the calling function */
- if (num >= n1 && num <= n2)
- return num;
- else /* If the input is valid but not in range, try again... */
- printf("The number must be between %d-%d. Try again: ",n1,n2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement