Subscribe For Free Updates!

We'll not spam mate! We promise.

Sunday 26 August 2012

C++ Code to Diplaying Prime Numbers from array



// Diplaying Prime Numbers from array
// Programmer name: Sohail Ahmed
// Dated: 16/05/2011

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

int prime[5]={1,3,5,7,9};

void main()
{
clrscr();
int n_div;
int divisor;
for(int count=0; count<=5; count++)
{
n_div=0;
divisor=1;
while(divisor<=prime[count])
{
if(prime[count]%divisor==0)
{
n_div++;
}
divisor++;
}
if(n_div==2)
{
cout<<prime[count]<<" ";
}
}
getch();
}

Socializer Widget By CodingLovers
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment