write the program for prime numbers?

Answer Posted / anesh kumar

# include <iostream.h>
# include <conio.h>
int main()
{
int i,j=2,num=0;
cout<<"\n Enter the number";
cin>>i%j>>i;
while(j<=i/2)
{
if(i%j==0)
{
Cout<<"%d Is not prime number"<<i;
ch=1;
break;
}
else
{
j++;
}
}
if(num==0)
{
Cout<<"%d Is prime number"<<i;
}
getch();
return 0;

}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is main a keyword in c?

853


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1705


Explain what is the benefit of using enum to declare a constant?

842


Can we add pointers together?

832


what is the difference between class and unio?

2120


where are auto variables stored? What are the characteristics of an auto variable?

856


What is structure and union in c?

836


What functions are used for dynamic memory allocation in c language?

870


Difference between Shallow copy and Deep copy?

1804


What is a far pointer in c?

799


What is the use of volatile?

846


If null and 0 are equivalent as null pointer constants, which should I use?

834


Write a program on swapping (100, 50)

876


What is dangling pointer in c?

831


Difference between macros and inline functions? Can a function be forced as inline?

964