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
Is main a keyword in c?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
Explain what is the benefit of using enum to declare a constant?
Can we add pointers together?
what is the difference between class and unio?
where are auto variables stored? What are the characteristics of an auto variable?
What is structure and union in c?
What functions are used for dynamic memory allocation in c language?
Difference between Shallow copy and Deep copy?
What is a far pointer in c?
What is the use of volatile?
If null and 0 are equivalent as null pointer constants, which should I use?
Write a program on swapping (100, 50)
What is dangling pointer in c?
Difference between macros and inline functions? Can a function be forced as inline?