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 |
is compiler do read the data line by line or not. ??
6 Answers LG Soft, Satyam, Tech Mahindra,
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
int a=20; int b=30; int c=40; printf("%d%d%d"); what will be the output?
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?
25 Answers Datamatics, Solartis, TCS, ThinkBox, Trine,
What are runtime error?
mplementation of stack using any programing language
what will be the output of this program........ main() { int a=2,b=4,c=6; printf("%d"); } why it gives the value of third variable.
main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } what is the output?
What is hungarian notation? Is it worthwhile?
What do the functions atoi(), itoa() and gcvt() do?
How do you determine if a string is a palindrome?
write a program to display the numbers having digit 9 in the given range from 1 to 100