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
Tell me when would you use a pointer to a function?
Why isn't any of this standardized in c? Any real program has to do some of these things.
What does c mean in basketball?
What is the use of getchar() function?
What are the differences between new and malloc in C?
Can we add pointers together?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
How variables are declared in c?
How can I find out how much free space is available on disk?
What is the difference between memcpy and memmove?
What is the difference between array and linked list in c?
What are the preprocessor categories?
Can an array be an Ivalue?
What is adt in c programming?
Write a program of advanced Fibonacci series.