how to find the given number is prime or not?
Answer Posted / shweta
#include<stdio.h>
#include<conio.h>
void main()
{
int n,ctr=2,flag=0;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=n/2;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");
flag=0;
getch();
}
Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
What do you mean by scope of a variable in c?
What are the usage of pointer in c?
List the different types of c tokens?
Explain enumerated types in c language?
Explain data types & how many data types supported by c?
how we can make 3d venturing graphics on outer interface
Is stack a keyword in c?
How can this be legal c?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
Can a file other than a .h file be included with #include?
Explain what is the difference between functions abs() and fabs()?
What is the argument of a function in c?
i have a written test for microland please give me test pattern
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
What is the concatenation operator?