write the program for prime numbers?

Answer Posted / naseer

main(){
int no,i,count=0;
printf("enter any no");
scanf("%d",&no);
//the main logic is here
for(i=2;i<no;i++){

if(no%2==0){
count++;
}
}
if(count>=1)// if the no is less than
//5 then it shows prime
{
printf("not Prime");
}

else
printf("prime");

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are void pointers in c?

576


What is the advantage of c?

613


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

1788


Here is a good puzzle: how do you write a program which produces its own source code as output?

602


What is a null pointer in c?

600






Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

2988


What happens if a header file is included twice?

602


What is page thrashing?

655


what is the function of pragma directive in c?

630


Once I have used freopen, how can I get the original stdout (or stdin) back?

631


What is time complexity c?

570


If you know then define #pragma?

678


What is header file definition?

573


write a program to display all prime numbers

1459


What is nested structure in c?

616