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
Explain which function in c can be used to append a string to another string?
What is the use of printf() and scanf() functions?
Write a simple code fragment that will check if a number is positive or negative.
What is selection sort in c?
What is 'bus error'?
How can a process change an environment variable in its caller?
How a string is stored in c?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
What is the difference between local variable and global variable in c?
What is main () in c?
When is a void pointer used?
Is struct oop?
What is non linear data structure in c?
Explain goto?
How do shell structures work?