write the program for prime numbers?

Answer Posted / gnanasekaran

int main()
{
int i,j,n,f=0;
printf("Enter the length\n");
scanf("%d",&n);
for(i=2;i<=n/2;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 ?    139 Yes 81 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c programing language?

803


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3209


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1137


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2393


What do you mean by a sequential access file?

793


What is cohesion in c?

721


What is the difference between fread buffer() and fwrite buffer()?

881


Write a code on reverse string and its complexity.

761


What is the code for 3 questions and answer check in VisualBasic.Net?

1888


What is the difference between far and near in c?

780


When is the “void” keyword used in a function?

1126


What is the size of array float a(10)?

878


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5681


What is meant by operator precedence?

857


Which built-in library function can be used to match a patter from the string?

964