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
What is difference between && and & in c?
Explain how can I prevent another program from modifying part of a file that I am modifying?
What does c mean in basketball?
What is the use of define in c?
Can you add pointers together? Why would you?
Can a pointer be volatile in c?
what is the difference between 123 and 0123 in c?
Who developed c language?
explain what is a newline escape sequence?
What is the auto keyword good for?
What is typedef struct in c?
Explain what is the difference between functions getch() and getche()?
Difference between exit() and _exit() function?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
Explain how do you sort filenames in a directory?