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 with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
Write a program to identify if a given binary tree is balanced or not.
What is calloc()?
What is the correct code to have following output in c using nested for loop?
What is the c language function prototype?
What is the size of array float a(10)?
Explain b+ tree?
What is pivot in c?
What is static volatile in c?
Why c is called top down?
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
How does sizeof know array size?
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
Where static variables are stored in memory in c?
What is the scope of global variable in c?