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


Please Help Members By Posting Answers For Below Questions

What do you mean by scope of a variable in c?

546


What are the usage of pointer in c?

703


List the different types of c tokens?

629


Explain enumerated types in c language?

606


Explain data types & how many data types supported by c?

586






how we can make 3d venturing graphics on outer interface

4012


Is stack a keyword in c?

637


How can this be legal c?

654


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

759


Can a file other than a .h file be included with #include?

686


Explain what is the difference between functions abs() and fabs()?

621


What is the argument of a function in c?

575


i have a written test for microland please give me test pattern

2183


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

583


What is the concatenation operator?

614