Search

Sabtu, 14 April 2012

Displays The Sequence of Primes

Today I will share the coding of the basic programming using Borland C + +, may be useful for the friend my friend as well.


Displays The Sequence of Primes


#include <iostream.h>
#include <conio.h>


void main(){
int input,arithmetic=0,i=1,b=2;

cout<<"input rate = ";cin>>input;
if (b==2)
          {cout<<b<<" ";
         b++;
         i++;}
while (i<=input)
    {
   for (int z=2;z<b;z++)
       {

      if (b%z==0)
          {arithmetic++;}
      }
      if (arithmetic==0)
      {cout<<b<<" ";
      i++;
      b++;}
      if (arithmetic>0)
      {b++;
      arithmetic=0;}

   }
getch();
}

good luck with my friends :)

Tidak ada komentar:

Posting Komentar