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
explain how do you use macro?
Can the sizeof operator be used to tell the size of an array passed to a function?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
Describe explain how arrays can be passed to a user defined function
What are the advantages and disadvantages of pointers?
What is pre-emptive data structure and explain it with example?
What does a pointer variable always consist of?
What is the use of #include in c?
Why is structure important for a child?
Explain what is meant by 'bit masking'?
What is array of pointers to string?
Explain spaghetti programming?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
Can you subtract pointers from each other? Why would you?