write the program for prime numbers?

Answer Posted / farhana parvin sunny

#include<stdio.h>

int main()
{

int i,j,n,f=0;
printf("Enter the length\n");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
for(j=2;j<i;j++)
{
if((i%j)==0)
{
f=1;
break;
}
f=0;
}
if(f==0)
printf("%d ",i);
}

}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.

1063


What are the advantages of c preprocessor?

713


how to construct a simulator keeping the logical boolean gates in c

1726


Explain goto?

713


What are the similarities between c and c++?

596






Why isn't it being handled properly?

645


What are the scope of static variables?

600


Write program to remove duplicate in an array?

597


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

687


What is character set?

683


Explain how can you avoid including a header more than once?

600


What does c mean in basketball?

561


How can I make it pause before closing the program output window?

579


the question is that what you have been doing all these periods (one year gap)

1617


What are the types of functions in c?

570