write the program for prime numbers?

Answer Posted / venkat reddy

#include<stdio.h>
main()
{
int i,n,count=0;
printf("enter a no.");
scanf("%d",&n);
for(i=2;i<n;i++)

{
if(n%i==0)
{
count++;
}
}
if(count>1)
{
printf("not prime no.");

}
else
printf("prime");
}

Is This Answer Correct ?    344 Yes 155 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of ?

626


Is there any demerits of using pointer?

631


What is sizeof int in c?

604


What is void main () in c?

735


What are derived data types in c?

612






main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

727


What is the need of structure in c?

566


Difference between MAC vs. IP Addressing

643


void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply

2226


Explain about the constants which help in debugging?

857


Why structure is used in c?

597


With the help of using classes, write a program to add two numbers.

620


Are there constructors in c?

598


What is use of null pointer in c?

572


Is c programming hard?

577