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 is the meaning of && in c?
how can u print a message without using any library function in c
What is Memory leakage ?
what is the value of 'i'? i=strlen("Blue")+strlen("People")/strlen("Red")-strlen("green")
7 Answers Cadence, JNTU, Zen Technologies,
main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr); } Find the Outputs?
What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack
Is there a way to switch on strings?
void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s",env[i]); }
Difference between null pointer and dangling pointer?
Explain how can you check to see whether a symbol is defined?
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555