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

program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1631


Why isnt any of this standardized in c?

641


What is the difference between new and malloc functions?

584


What is the -> in c?

588


How can I get the current date or time of day in a c program?

654






Write a program to print ASCII code for a given digit.

690


Do pointers need to be initialized?

568


Why do some versions of toupper act strangely if given an upper-case letter?

636


Do pointers store the address of value or the actual value of a variable?

613


Differentiate between functions getch() and getche().

627


What is c language in simple words?

598


What are the disadvantages of c language?

624


Why string is used in c?

586


What is the advantage of a random access file?

642


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

627