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
When should structures be passed by values or by references?
What is static memory allocation? Explain
What are the main characteristics of c language describe the structure of ac program?
How can you find the exact size of a data type in c?
pierrot's divisor program using c or c++ code
Why does this code crash?
Is c is a procedural language?
What are the features of c languages?
What is double pointer?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What is data types?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
How is a null pointer different from a dangling pointer?
What is variable initialization and why is it important?
Write a program to print "hello world" without using a semicolon?