Thursday, August 18, 2011

Program to find a number is prime or not

/*Program to find a number is  prime or not*/


#include "stdio.h"

#include "conio.h"

void main()

{

int a,b,c=1;

clrscr();

printf("enter the number : ");

scanf("%d",&a);

for(b=2;b<=(a/2);b++)

{

if(a%b==0)

{

c++;

}

}

if(c>1)

{

printf("not prime");

}

else

{

printf("prime ");

}



getch();

}

OUTPUT : -
enter the number : 17
prime

enter the number : 15
not prime





r u unable to understand this program??????????TRY THESE






1. Email us at chelperr@gmail.com



2. Post your question in the comment box.



3. You can give us your email ID also.



4. If you want to ask a program/topic or wanted introduce any discussion topic then just email at chelperr@gmail.com or drop a comment in the comment box.

No comments:

Post a Comment