how to find the given number is prime or not?
Answer Posted / amit kumar
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,flag=0,ctr;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=sqrt(n);ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==0)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}
Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
What is a union?
What is #ifdef ? What is its application?
Can we change the value of #define in c?
Does c have class?
Is c is a low level language?
What is use of pointer?
What is omp_num_threads?
How would you obtain the current time and difference between two times?
Differentiate between a structure and a union.
What is use of null pointer in c?
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
Explain what does it mean when a pointer is used in an if statement?
What is void c?
What are the advantages of using Unions?
Describe the difference between = and == symbols in c programming?