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 variable and explain rules to declare variable in c?
Why c is called top down?
What is meant by initialization and how we initialize a variable?
to find the closest pair
Explain the meaning of keyword 'extern' in a function declaration.
How can you be sure that a program follows the ANSI C standard?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
Is swift based on c?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
Why do we use null pointer?
Is multithreading possible in c?
Write a program for Overriding.
Is there a way to jump out of a function or functions?