how to find the given number is prime or not?
Answer Posted / arunkumar mt
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n,flag=0;
clrscr();
printf("enter a number\n");
scanf("%d",&n);
for(i=2;i<=sqrt(n);i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
if(flag==0)
{
printf("given number %d is prime",n);
}
else
{
printf("given number %d is not prime",n);
}
getch();
}
| Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
Is it possible to execute code even after the program exits the main() function?
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
What is #include conio h?
Explain how can I convert a number to a string?
What is the difference between typedef and #define?
How important is structure in life?
how to find binary of number?
What is difference between arrays and pointers?
Which is the best website to learn c programming?
Explain high-order and low-order bytes.
Explain the term printf() and scanf() used in c language?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What is printf () in c?
Explain the array representation of a binary tree in C.