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 |
Can a variable be both constant and volatile?
to get a line of text and count the number of vowels in it
Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
What is an lvalue and an rvalue?
Write a program to print numbers from 1 to 100 without using loop in c?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
What the different types of arrays in c?
Describe static function with its usage?
what is function pointer?
what are you see during placement time in the student.
0 Answers Goldman Sachs, TCS, Tech Solutions,
What is the purpose of main() function?
print the pattern 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 if n=5