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
What are the advantages and disadvantages of pointers?
How can I generate floating-point random numbers?
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
What is getch?
What are the c keywords?
What are the types of data structures in c?
Is c pass by value or reference?
When would you use a pointer to a function?
Explain what are bus errors, memory faults, and core dumps?
Differentiate between Macro and ordinary definition.
how should functions be apportioned among source files?
What is the use of parallelize in spark?
What is clrscr ()?
What are linked lists in c?
What are local variables c?