write the program for prime numbers?

Answer Posted / karthik

#include<stdio.h>
#include<conio.h>
void main()
{
int n,flag;
clrscr();
printf("\n Enter prime no\n");
scanf("%d",&n);
for(int i=2;i<=n/2;i++)
{
if(n%i==0)
{
flag=0;
break;
}
}
if(flag==0)
printf("\n%d is not prime",n);
else
printf("\n %d is prime",n);
getch();
}

Is This Answer Correct ?    21 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are pointers? What are stacks and queues?

585


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

917


What is structure padding and packing in c?

627


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1256


Explain the properties of union. What is the size of a union variable

720






How can I do serial ("comm") port I/O?

695


write a c program for swapping two strings using pointer

2100


What is the difference between array and pointer in c?

586


if p is a string contained in a string?

1412


any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above

649


Who developed c language and when?

590


please explain every phase in the "SDLC" in the dotnet.

2182


What are the functions to open and close the file in c language?

597


What does %p mean?

603


Ow can I insert or delete a line (or record) in the middle of a file?

579