find out prime number with c programming 09-28-2011, 09:22 PM
#1
hey guys, this post is about to find out give number is prime or not, exept 2.
thanks for reading
Code:
/*program is for finding given number is prime or not*/
main()
{
int x,y,z;
clrscr();
printf("\t\t\t*PROGRAM FOR FINDING PRIME NUMBER*\n\n");
printf("enter number:");
scanf("%d",&x);
y=x;
for (z=2;z<x;++z)
{
if (x%z==0)
break;
}
if (z==y)
printf("the given number is prime");
else
printf("the given number is not prime");
getch();
}
thanks for reading
![[Image: 262s21x.jpg]](http://i45.tinypic.com/262s21x.jpg)