write the program for prime numbers?

Answer Posted / d.sukumar

void main()
{
int i,k;int count=0;
int n;
printf("enter a no");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
k=n%i;
if(k==0)
{
count++;
}
}
if(count==1)
printf("prime");
else
printf("not prime");
}

Is This Answer Correct ?    1 Yes 0 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?

547


Explain what are the __date__ and __time__ preprocessor commands?

596


Is fortran faster than c?

587


What is the best way to store flag values in a program?

583


What is a pointer value and address in c?

636






Explain how do you determine the length of a string value that was stored in a variable?

673


Write a C program to count the number of email on text

1422


Tell me with an example the self-referential structure?

568


What are global variables and explain how do you declare them?

582


What is anagram in c?

521


What is indirection?

657


How can I ensure that integer arithmetic doesnt overflow?

612


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

2253


we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above

640


Can math operations be performed on a void pointer?

593