Subscribe to The C++ Code Factory        RSS Feed
-----

coddie#1_

Icon Leave Comment
A program that displays all the prime numbers between 1 and 100.
#include <iostream.h>
#include <conio.h>

void main()
{
     clrscr();
     int factorscount;
     cout<<"Prime Numbers 1-100"<<endl;
     for(int i=2;i<=100;i++)
     {
             factorscount=0;
             for(int j=1;j<=i;j++)
             {
                     if(i%j==0)
                     factorscount++;
             }
             
             if(factorscount==2)
             cout<<i<<"\t";
             
     }
     getch();
     
}


0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

Tags

    Recent Entries

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)

    Categories

    November 2018

    S M T W T F S
        123
    45678910
    11121314151617
    181920 21 222324
    252627282930