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 the difference between union and anonymous union?
Is c still relevant?
How can I implement a delay, or time a users response, with sub-second resolution?
What is the total generic pointer type?
How can I direct output to the printer?
What is the use of a ‘ ’ character?
given post order,in order construct the corresponding binary tree
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
What does c in a circle mean?
What are the different types of control structures in programming?
How to define structures? ·
What are the primitive data types in c?
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
What are dangling pointers in c?
What is a static function in c?