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

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

1616


console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above

645


Is void a keyword in c?

566


Why is it usually a bad idea to use gets()? Suggest a workaround.

890


how to write a c program to print list of fruits in alpabetical order?

1779






What is the full form of getch?

573


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

1433


What is clrscr ()?

627


What is call by reference in functions?

551


What are extern variables in c?

539


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1505


What is multidimensional arrays

622


Where does the name "C" come from, anyway?

632


How to Throw some light on the splay trees?

613


Why is main function so important?

605