how to find the given number is prime or not?
Answer Posted / rajamanickam.m
#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 ? | 3 Yes | 2 No |
Post New Answer View All Answers
What is difference between structure and union in c programming?
What is 2 d array in c?
what are the different storage classes in c?
What is string concatenation in c?
What is the purpose of ftell?
What are Macros? What are its advantages and disadvantages?
what is a function method?give example?
Why we write conio h in c?
What is the benefit of using #define to declare a constant?
What functions are used in dynamic memory allocation in c?
Why can't I perform arithmetic on a void* pointer?
What is an operator?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
How do I determine whether a character is numeric, alphabetic, and so on?
Can you define which header file to include at compile time?