write the program for prime numbers?
Answers were Sorted based on User's Feedback
Answer / dharanya
Answer
# 10
Find all primes not larger than N.
I think it is the most efficient algorithm to find all
primes no larger than N.
int main(void)
{
int i,j, N;
int *pPrimes;
int nPrimes, is_prime;
printf("Input N:");
scanf("%d", &N);
pPrimes = new int [N/2];
nPrimes = 0;
for(i = 2; i<=N; i++)
{
is_prime = 1;
for(j=0;j<nPrimes; j++)
if (i%pPrimes[j] == 0)
{
is_prime = 0; break;
}
if (is_prime)
{
pPrimes[nPrimes++] = i;
}
}
printf("%d primes found less than %d:\n", nPrimes, N);
for (i=0; i< nPrimes; i++)
printf("%d ", pPrimes[i]);
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / natalija
I got one question! how can i make program in LSL (linden->second life script language) for prime numbers...not to cheek, but for readouot prime numbers?
Is This Answer Correct ? | 7 Yes | 10 No |
Answer / neetu singh
#include<iostream.h>
#include<conio.h>
void main()
{
int n,i;
for(i=0;i<10;i++)
{
if(n<=o)
}
{
cout<<"number is prime");
cout<<"number is not prime");
getch();
}
Is This Answer Correct ? | 1 Yes | 4 No |
What does emoji p mean?
write an interactive program to generate the divisors of a given integer.
implement NAND gate logic in C code without using any bitwise operatior.
What are the different pointer models in c?
what are the stoge class in C and tel the scope and life time of it?
5) Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.without using big int and exponential function
write an algorithm and a program to count the number of elements in a circularly singly linked list
Why main function is special give two reasons?
What are different types of pointers?
What is atoi and atof in c?
c programming of binary addition of two binary numbers
What does malloc () calloc () realloc () free () do?