Introduction

The main purpose of this blog is to share our experience with the world and get experience from the world. This will be a new venture for us and we are sure, we shall learn a lot with it. we will try to Explore our mind which will be very helpful for all us. As from its name, its a blog covering all the topics. we will try to post all the interesting topics and give our opinion. Do give your point of view in comments.


"NAVIGATE VIA BLOG ARCHIVE ON RIGHT TO GET WHAT YOU ARE LOOKING FOR"


Thursday, January 27, 2011

C CODE FOR PRIME NUMBER way2

//This one is a little complicated

#include<stdio.h>
int main()
{ int x,q,no,s,originalno;
  printf("Enter the Number: ");
  scanf("%d",&no);
  originalno=no;
  for ( x=2;(no/x)>=1;x++)
      { if ((no%x)==0)      
         {
      if (x==originalno)
          {printf("%d is a PRIME number\n",originalno);}
      s=(no/x);           
          no=s;         
          x=x-1;       
         }
      }
if(x!=originalno)
  {printf("%d is not a prime number\n",originalno);}
  return 0;
}

1 comment:

Related Posts with Thumbnails