write the program for prime numbers?

Answer Posted / dinesh kumar.s

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,a;
clrscr();
printf("program created by dinesh mca anna university\n");
printf("enter the number\n");
scanf("%d",&a);

j=a;

if( a%2==0 || a%3==0 )
{
for(i=2;i<=a;i++)
if(a%i==0)
if (i==j)
{
printf("prime number");
break;
}

else
{
printf("not");
break;
}
}
else
{
printf("prime number");

}

getch();
}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is LINKED LIST? How can you access the last element in a linked list?

633


Explain a pre-processor and its advantages.

630


Is it possible to execute code even after the program exits the main() function?

811


What is c definition?

743


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

14960






What is oops c?

607


What is meant by int main ()?

716


What is function pointer c?

586


How is a structure member accessed?

584


How do you define CONSTANT in C?

651


How we can insert comments in a c program?

630


What is the difference between array and linked list in c?

600


What's the right way to use errno?

622


What is the purpose of 'register' keyword in c language?

627


How does sizeof know array size?

627