Home » NO IDEA » Prime Number

Prime Number

Blog Stats

  • 15,880 hits
December 2012
M T W T F S S
« Sep   Jan »
 12
3456789
10111213141516
17181920212223
24252627282930
31  
//prime number or not
#include<stdio.h>
int main()
{
 int num,i,count=0;
 printf("\n Enter the Number");
 scanf("%d",&num);
 for(i=1;i<=num;i++)
 {
 if(num%i==0)
 count++;
 }
 if(count==2)
 {
 printf("\n It is prime number");
 }
 else
 {
 printf("\n It is not a prime number");
 }
 return 0;
}

//Prime number Genearation #include<stdio.h> int main() { int range,j; printf("\n Enter the Range"); scanf("%d",&range); printf("\n The prime number are \n"); for(j=2;j<range;j++) { int num,i,count=0; num=j; for(i=1;i<=num;i++) { if(num%i==0) count++; } if(count==2) { printf("\n\t%d",num); } } return 0; }

Advertisements

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: