#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,flag;
clrscr();
printf("================================\n\n");
printf("Finding if a Number is Prime or Not\n\n");
printf("================================\n\n");
printf("Enter a Number\n");
scanf("%d",&n);
for(i=2;i<n/2;i++)
{
if(n%i==0)
{
flag=0;
break;
}
}
if(flag==0)
printf("Number is not prime");
else
printf("Number is prime");
getch();
}
This programme will read a number from user and spit out weather the number is prime or not.
Download Wordpress Themes
http://themeforest.net/?ref=ppshobi

No comments:
Post a Comment