Click here to Skip to main content
15,892,298 members

Write a C/C++ program to generate prime number list and check whether a number is prime or not

Revision 1
I can write the code for "Sieve of Eratosthene" to generate all the prime number upto n. But I want to write a program that will generate and index all the prime number (up to n) into an array, than check whether a number is prime or not. Can anyone please help me to do it?

For Example: if n = 10, than the prime number is 2 3 5 7. Index tham into an array a[] = {2, 3, 4, 7}. Than write a program and press a number as input from keyboard, than check the number is prime or not. I know that there is a simple way to check whether a number is prime or not but I want to do it by the above way. How can I do that???
Posted 9-Nov-12 1:44am by Ihteshamul Alam.
Tags: ,
  Print Answers RSS
Top Experts
Last 24hrsThis month