write the program for prime numbers?

Answer Posted / akhilesh singh(m.c.a-iisem ois

main()
{
int i,j=2,ch=0;
clrscr();
printf("\nENTER ANY NUMBER");
scanf("%d",&i);
while(j<=i/2)
{
if(i%j==0)
{
printf("%d IS NOT PRIME",i);
ch=1;
break;
}
else
{
j++;
}
}
if(ch==0)
{
printf("%d IS PRIME",i);
}
}

Is This Answer Correct ?    1243 Yes 384 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I dynamically allocate arrays?

603


What does typeof return in c?

648


Write a program for finding factorial of a number.

640


When is a void pointer used?

685


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1531






Why is c faster?

602


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

1464


What is meant by keywords in c?

629


Explain main function in c?

636


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

2749


What is the significance of scope resolution operator?

869


What is meant by int main ()?

731


what is ur strangth & weekness

1836


What does stand for?

611


Explain enumerated types.

609