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
In C language, a variable name cannot contain?
Explain pointers in c programming?
I have a varargs function which accepts a float parameter?
Can we initialize extern variable in c?
What are the data types present in c?
What is difference between structure and union in c programming?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
Where in memory are my variables stored?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
Can you define which header file to include at compile time?
what is the diffrenet bettwen HTTP and internet protocol
What is extern c used for?
What are the features of the c language?
What is getch c?
Are c and c++ the same?