how to find the given number is prime or not?

Answer Posted / rahul tiwari

main()
{
int n,ctr=2,flag=0;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=n/2;ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==1)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
flag=9
getch();
}

Is This Answer Correct ?    8 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

C language questions for civil engineering

1245


Why is struct padding needed?

633


What is unary operator?

660


What is #line in c?

563


Can you return null in c?

597






How pointers are declared?

562


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

1879


Is main is a keyword in c?

610


What is the difference between null pointer and wild pointer?

640


i want to know the procedure of qualcomm for getting a job through offcampus

1939


What is the purpose of & in scanf?

598


provide an example of the Group by clause, when would you use this clause

1709


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

610


How can I implement sets or arrays of bits?

607


What is the significance of an algorithm to C programming?

596