write the program for prime numbers?

Answer Posted / anjana rao .ch

\*Write a program wither given number is prime or not */
\*I think it is different to others (BY ANJAN)*/
#include<stdio.h>
main()
{
int n,a=3;
printf("Enter Number");
scanf("%d",&n);
if(n==2)
{
printf("Given Number is PRIME");
exit (0);
}
if(n==3)
{
printf("Given Number is PRIME");
exit (1);
}
if(n%2==0)
{
printf("Given Number is NOT PRIME");
exit (2);
}
while(a<=n/2)
{
if(n%a==0)
{
printf("Given Number is NOT PRIME");
exit (3);
}
a=a+2;
}
printf("Given Numbr is 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 is the difference between array and pointer?

569


Why isnt there a numbered, multi-level break statement to break out

587


Explain do array subscripts always start with zero?

761


write a proram to reverse the string using switch case?

2469


What is extern variable in c with example?

538






a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none

631


how do you execute a c program in unix.

636


Write a program to find the biggest number of three numbers in c?

588


What is the heap?

685


Differentiate between static and dynamic modeling.

620


What do you know about the use of bit field?

612


When is a “switch” statement preferable over an “if” statement?

650


What is difference between && and & in c?

597


Explain what is meant by high-order and low-order bytes?

635


What are the different types of endless loops?

624