February 4, 2011

C Program for to find Prime Number

A Prime Number (or a prime) is a natural number that has exactly two distinct natural number divisors: 1 and itself.

The prime numbers under 100:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.


Code:

//C Program To Print Prime no. till limit
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,c=1;
clrscr();
printf("Enter the limit\n\n");
scanf("%d",&n);
while (c<=n)
{
i=2;
while(i<=c)
{
if(c%i==0)
break;
i++;
}
if(i==c)
printf("\n%d",c);
c++;
}
getch();
}

Hope you liked my posts, give comments if you have any doubts.. :)

Related Posts :



Categories: ,

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails