how to find the given number is prime or not?
Answer Posted / shrikanth s.hallikhed
#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==1)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
What is void c?
Is c a great language, or what?
Write a program to swap two numbers without using third variable in c?
c language interview questions & answer
is it possible to create your own header files?
What is #ifdef ? What is its application?
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
What does it mean when the linker says that _end is undefined?
What does. int *x[](); means ?
Explain how can a program be made to print the name of a source file where an error occurs?
Can you subtract pointers from each other? Why would you?
Why is c called a structured programming language?
Explain what is wrong with this program statement? Void = 10;
What is the purpose of type declarations?