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
How do you view the path?
Can you write the function prototype, definition and mention the other requirements.
What are loops c?
How is a macro different from a function?
Where static variables are stored in memory in c?
How can I remove the trailing spaces from a string?
What are enumerated types?
What are the advantages of using macro in c language?
If the size of int data type is two bytes, what is the range of signed int data type?
Is it valid to address one element beyond the end of an array?
What is methods in c?
Describe static function with its usage?
What are the different properties of variable number of arguments?
What's the right way to use errno?
What are file streams?