write the program for prime numbers?

Answer Posted / akhilesh singh(m.c.a-iisem ois

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 ?    1243 Yes 384 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of the function in c?

604


Explain what is the difference between text files and binary files?

622


what is the structure pointer?

1648


Why are algorithms important in c program?

625


Write a program with dynamically allocation of variable.

607






What is function what are the types of function?

563


What is difference between array and structure in c?

583


Can we replace the struct function in tree syntax with a union?

786


What is the advantage of a random access file?

642


What are the differences between Structures and Arrays?

614


Explain what is a const pointer?

643


Does c have circular shift operators?

734


What does the characters “r” and “w” mean when writing programs that will make use of files?

862


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

3129


What is string in c language?

630