First is the main menu requesting the selection function, then once the selection is chosen, it will ask for the lower and upper limits.

I already have functions option1 through option3 completed. Function four is supposed to be print prime numbers that are not part of Fibonacci. When I enter lower limit as "1" and upper limit as "20." It should print only numbers: 7, 11, 17, 19, but instead prints all prime numbers from 1 through 20. Not sure what I am doing wrong at all...

#include <iostream> #include <conio.h> using namespace std; int print_nums(); bool isPrime(); int option1(int, int); int option2(int, int); int option3(int, int); int option4(int, int); void main() { int selection, lower, upper, count; do { selection = print_nums(); if(selection == 6) break; cout << "Enter lower and upper limits: "; cin >> lower >> upper; if(selection == 1) count = option1(lower, upper); if(selection == 2) count = option2(lower, upper); if(selection == 3) count = option3(lower, upper); if(selection == 4) count = option4(lower, upper); cout << count << " numbers met the criteria." << endl; }while(selection < 6); cout << "\nThank you for using my program. -Jeff Lima."; _getch(); } bool isPrime(int n) { for(int i = 2; i < n / 2 + 1; i++) if(n % i == 0) return false; return true; } int print_nums() { int selection; do { cout << "\nChoose one of the following by entering the corresponding number:" << "\n1. Prime numbers." << "\n2. Fibonacci numbers." << "\n3. Prime numbers that are also part of the Fibonacci series." << "\n4. Prime numbers that are not part of Fibonacci series." << "\n5. Fibonacci numbers that are not prime numbers." << "\n6. Quit." << "\nEnter selection: "; cin >> selection; }while(selection < 1 || selection > 6); return selection; } int option1(int lower, int upper) { int count = 0; for(int i = lower; i <= upper; i++) { if(isPrime(i)) { cout << i << ", "; count++; } } cout << "\b\b." << endl; return count; } int option2(int lower, int upper) { int count = 0, num1 = 0, num2 = 1, sum = num1 + num2; if(lower <= num1) { cout << num1 << ", " << num2 << ", "; count = 2; } else if(lower <= num2) { cout << num2 << ", "; count = 1; } do { if(sum >= lower) { cout << sum << ", "; count++; } num1 = num2; num2 = sum; sum = num1 + num2; }while(sum <= upper); cout << "\b\b." << endl; return count; } int option3(int lower, int upper) { int count = 0, num1 = 0, num2 = 1, sum = num1 + num2; if(lower <= num1 && isPrime(num1)) { cout << num1 << ", " << num2 << ", "; count = 2; } else if(lower <= num2 && isPrime(num2)) { cout << num2 << ", "; count = 1; } do { if(sum >= lower && isPrime(sum)) { cout << sum << ", "; count++; } num1 = num2; num2 = sum; sum = num1 + num2; }while(sum <= upper); cout << "\b\b." << endl; return count; } int option4(int lower, int upper) { int count = 0, num1 = 0, num2 = 1, sum = num1 + num2; for(int i = lower; i <= upper; i++) { if(isPrime(i)) { do { if(sum != i) { cout << i << ", "; count++; } num1 = num2; num2 = sum; sum = num1 + num2; }while(sum <= upper); } } cout << "\b\b." << endl; return count; }