how to find the given number is prime or not?
Answer Posted / amit kumar
#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==0)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}
Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
What are the Advantages of using macro
What is modeling?
can anyone suggest some site name..where i can get some good data structure puzzles???
Difference between MAC vs. IP Addressing
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
What are void pointers in c?
What does a function declared as pascal do differently?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
Why malloc is faster than calloc?
What is enumerated data type in c?
What is the significance of an algorithm to C programming?
What is %lu in c?
What are the benefits of organizational structure?
Write the syntax and purpose of a switch statement in C.
What is nested structure?