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

What is getche() function?

806


Explain how do you convert strings to numbers in c?

808


How can you determine the maximum value that a numeric variable can hold?

869


What is dangling pointer in c?

805


What is a example of a variable?

748


struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

988


how to introdu5ce my self in serco

1727


What is the description for syntax errors?

823


What is the use of printf() and scanf() functions?

810


C program to find all possible outcomes of a dice?

2051


What are qualifiers in c?

766


how to count no of words,characters,lines in a paragraph.

4136


How many loops are there in c?

802


An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode

834


What are directives in c?

732