Simple question. I am trying to build a simple script that will ask you for a number. That integer will be the amount of numbers you will enter in total. Then your program finds the biggest number and the smallest. And I have build that. Easy.
printf("\nEnter the size of the array: ");
printf("\nEnter %d numbers: ", size);
printf("Smallest element: %d",small);
My question is, how can I tell to check for conditions. For instance, the user can input only positive numbers and smaller than 100. So if you enter -4 or 201 an Error has to be displayed telling you to try again.
Any ideas as of how we can do that in a simple way. Or even point me to the right direction.
I appreciate it. Thank you. Why do you feel that you must store the numbers? Consider looking for the smallest/largest as each number is entered, then you don't have to have a static limit (50) on how many numbers can be accepted. Designing programs to not have static limits is generally preferable.
以上就是C create Array and check for Input Error的详细内容，更多请关注web前端其它相关文章！