Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- answer_Suresh_Kumar_question
- Suresh Kumar C , C++ , C# , Java, SQL , VB. net, Python , MVC , Web Programming
- 新成員 · 14小時 ·
- My program is not showing correct results.it is compiling successfully. please tell me the error.
- https://www.facebook.com/groups/prog11/permalink/2482225488515644/
- */
- #include <cstdio>
- #include <iostream>
- using namespace std;
- int main(int argc, char *argv[]) {
- int min = 0, max = 0;
- bool flag = true;
- cout << "enter the lower limit of number: ";
- cin >> min;
- cout << "enter the upper limit of number: ";
- cin >> max;
- if (max <= min) {
- cout << "Error, upper limit must larger than lower limit." << endl;
- return -1;
- }
- if (min < 2) {
- min = 2;
- }
- /* Look at here. */
- for (int i = min; i <= max; i++) {
- flag = true;
- for (int j = 2; j < i; j++) {
- if (i%j == 0) {
- flag = false;
- break;
- }
- }
- if (flag == true) {
- cout << i << ", ";
- }
- }
- cout << endl << "are prime out if given elements" << endl;
- while (getchar() != '\n' && getchar() != EOF);/* Clear buffer */
- cout << "Press enter to continue . . . ";
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement