This is for c if it works i will rate right away Thanks 623
This is for c++, if it works i will rate right away! Thanks
6.23: isPrime Function
 Use the isPrime function that you wrote in Programming Challenge 21 in a program that reads in an integer that is less than 3001 stores a list of all the prime numbers from 2 through that number in a file name d \"PrimeList.txt\".
Prompts And Output Labels. No prompts, no labels. After closing the file, the program writes \"Prime numbers written to PrimeList.txt.\" on a line by itself in standard output .
Input Validation If the value read in exceeds 3000, the program silently terminates.
Solution
// C++ determine prime numbers
#include <iostream>
 #include <iomanip>
 #include <fstream>
 #include <vector>
 #include <stdlib.h>   
 #include <math.h>
using namespace std;
bool isPrime(int number)
 {
 // return false if compsote nuber is found
 for (int i=2; i<number; i++)
 {
 if (number % i == 0)
 {
 return false;
 }
 }
   
 return true;
 }
 int main()
 {
int number;
 cout << \"Enter integer that is less than 3001: \";
 cin >> number;
if(number > 3000)
 return 0;
ofstream outputFile;
 outputFile.open (\"PrimeList.txt\");
   
for (int i = 2; i <= number; ++i)
 {
 if(isPrime(i) == true)
 outputFile << i << endl;
}
cout << \"Prime numbers written to PrimeList.txt\ \";
outputFile.close();
 return 0;
 }
 /*
output:
 Enter integer that is less than 3001: 100
 Prime numbers written to PrimeList.txt
PrimeList.txt
 2
 3
 5
 7
 11
 13
 17
 19
 23
 29
 31
 37
 41
 43
 47
 53
 59
 61
 67
 71
 73
 79
 83
 89
 97
*/


