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
Explain how can I read and write comma-delimited text?
pierrot's divisor program using c or c++ code
What are header files in c programming?
Is this program statement valid? INT = 10.50;
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
What is the use of the function in c?
What does node * mean?
What is the benefit of using #define to declare a constant?
Can we access array using pointer in c language?
How many levels of pointers can you have?
Can we use any name in place of argv and argc as command line arguments?
how to find binary of number?
Difference between exit() and _exit() function?
Write the control statements in C language
Explain pointer. What are function pointers in C?