Write a program that will prompt a user to enter an integer between 2 and 999, inclusive.

As output, the program will display all prime integers between 2 and the user-input value.

This program will use a process of “cancellation to identify the required prime values. To do so, the program will do the following:
1) store the integers 0, 0, 2, 3, 4, . . ., 997, 998, 999 (note: 0 and 1 will not be considered);
2) prompt the user for an integer between 2 and 999, inclusive;
3) using 2 (the first prime integer), the program will proceed to cancel all multiples of 2 found in the remaining set by setting each multiple to 0;
4) the program will then move to the next non-zero integer (which will be the next prime, since it was not cancelled by the process in #3 above) and repeat the process in #3 above, but now using this new value;
5) the program will continue this process of cancellation until the user-input value is reached.

As output, the program will display all prime values between 2 and the user-input value.

i don't understand how to do this.

The description is quite exhaustive. I suggest you read it and try yourself while waiting for someone to write your code for you so you can in the last 5 minutes before your homework is due slap something together which has a passing chance of coming near to working because noone is going to write your code for you.

Why don't kids today even TRY to do their own assignments?

This article has been dead for over six months. Start a new discussion instead.