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
What is the difference between array and pointer?
Why isnt there a numbered, multi-level break statement to break out
Explain do array subscripts always start with zero?
write a proram to reverse the string using switch case?
What is extern variable in c with example?
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
how do you execute a c program in unix.
Write a program to find the biggest number of three numbers in c?
What is the heap?
Differentiate between static and dynamic modeling.
What do you know about the use of bit field?
When is a “switch” statement preferable over an “if” statement?
What is difference between && and & in c?
Explain what is meant by high-order and low-order bytes?
What are the different types of endless loops?