Sinisterly
find out prime number with c programming - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C)
+--- Thread: find out prime number with c programming (/Thread-find-out-prime-number-with-c-programming)



find out prime number with c programming - jammy7777 - 09-28-2011

hey guys, this post is about to find out give number is prime or not, exept 2.

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


RE: find out prime number with c programming - jammy7777 - 10-09-2011

(10-09-2011, 03:42 AM)esunly Wrote: I like this program. You are very critical to think of it.

thank you. if you need more help in c then pm me


RE: find out prime number with c programming - Solixious - 10-18-2011

According to me, it'll display 2 also as prime number.. So its perfect.


RE: find out prime number with c programming - The Alchemist - 10-26-2011

This program is perfect... It'll work smoothly..