write the program for prime numbers?

Answer Posted / manish kumar

main()
{
int i,j=2,ch=0;
clrscr();
printf("\nENTER ANY NUMBER");
scanf("%d",&i);
while(j<=i/2)
{
if(i%j==0)
{
printf("%d IS NOT PRIME",i);
ch=1;
break;
}
else
{
j++;
}
}
if(ch==0)
{
printf("%d IS PRIME",i);
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stream water?

656


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

587


What does the function toupper() do?

657


How can you allocate arrays or structures bigger than 64K?

683


Difference between strcpy() and memcpy() function?

676






When should a type cast be used?

575


What is p in text message?

540


Explain what is the difference between a free-standing and a hosted environment?

635


What is the difference between constant pointer and constant variable?

748


What is data structure in c and its types?

596


What is string concatenation in c?

568


What does printf does?

746


What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

1492


What is a void * in c?

597


Write a program that accept anumber in words

1252