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 c value paradox and how is it explained?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What is openmp in c?
What is 'bus error'?
What is array in C
What is use of integral promotions in c?
Are the outer parentheses in return statements really optional?
What is the difference between local variable and global variable in c?
Explain what is #line used for?
plz let me know how to become a telecom protocol tester. thank you.
What is malloc return c?
Can a variable be both static and volatile in c?
What is "Duff's Device"?
What are global variables?
Explain what are the different data types in c?