NBA - Boston Celtics

Sunday 18 November 2012

EVEN OR ODD OR PRIME



#include<iostream.h>
void main()
{
int num;
cout<<"enter any number : ";
cin>>num;
if(num==1)
{
cout<<"prime and neither even nor odd ";
}
else if(num==2)
cout<<"prime and even";
else
{
for(int i=2;i<=num/2;i++)
{
if(num%2==0)
cout<<"composite and even";
else
cout<<"composite and odd";
            break;

}

}
}

No comments:

Post a Comment