Write a program to print the prime numbers from 1 to 100?

Answer Posted / m santhosh

int count=0;
int number=100; //// print Prime no's from 1 to 100
for(int i=1;i<=number;i++)
{
count=0;
for(int j=1;j<=i;j++)
{
if((i%j==0))
{
count++;
}

}
if(count<=2)
{
printf("\nPrime Number = %d",i);

}

}

Is This Answer Correct ?    14 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a pointer be null?

558


What is output redirection?

686


What is ponter?

768


how many key words availabel in c a) 28 b) 31 c) 32

631


Can you please explain the difference between syntax vs logical error?

688






How do you write a program which produces its own source code as output?

603


What are c preprocessors?

672


What does dm mean sexually?

806


Which is best linux os?

558


How macro execution is faster than function ?

660


Write a program that accept anumber in words

1248


Explain what are binary trees?

604


Why should I use standard library functions instead of writing my own?

667


Is exit(status) truly equivalent to returning the same status from main?

581


What is the significance of scope resolution operator?

851