Sunday, 7 April 2013

Prime no program in c++


#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main()
{
 int num,i,num1;
 cout<<"enter no=";
 cin>>num;
 i=2;
 num1=num-1;
 while(i<=num1)
 {
  if(num%i==0)
  {
cout<<"not a prime no\n";
break;
}
i++;
  }
  if(i==num)
cout<<"prim no\n";
getch();
 }
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments:

Post a Comment