ACP1_4

#include<stdio.h> int prime(int); void main() { int no,flag; clrscr(); printf("\nEnter a no. : "); scanf("%d",&no); flag=prime(no); if(flag==1) printf("%d is prime.",no); else printf("%d is not prime.",no); getch(); } int prime(int num) { int a,b,half,flag; half=num/2; for(a=2;a<=half;a++) { if(num%a==0) return 0; else flag=1; } if(num==2||num==3) return 1; else return flag; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.