Tuesday, September 27, 2011

C Program To Find All Prime Numbers From 1 To Infinite

To Check The Number is Prime or Not


Variables used
i=Loop control
n-Number


Program
#include<stdio.h>
#include<process.h>
main( )
{
int i,n;
printf("Enter the Number");
scanf("%d",&n);
for(i=0;i<=n/2;i++) //Used for small Number only
{
if(n%i==0)
{
printf("The Number is Not Prime");
exit(0);
}
}
printf("The Number is Prime",c);
}

Output
Enter the number 5
The number is prime 
Enter the number 4
The number is Not prime





Tags : C program to find prime numbers , c program to check the given number is prime or not ,c program for prime number , prime or not c program , code for finding the given number is prime or not , free c program for check whether the given number is prime or not

No comments:

Post a Comment