Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write the prime no program in c++?

Answer Posted / adnan sheikh

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

main()
{
int i,j,num;
cout<<"enter nay number";
cin>>num;
j=static_cast<int>(num/2);
for(int i=2;i<=j;i++)
{
if(!(num%i))
break;
}
if(i==(j+1))
cout<<"number is prime";
else
cout<<"number is not prime";
getch();
}

Is This Answer Correct ?    8 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to declare a function pointer?

994


How do we implement inheritance in c++?

1127


What are the two types of polymorphism?

1131


What is exception handling? Does c++ support exception handling?

1031


What is class invariant in c++?

1227


What is :: operator in c++?

1049


What is isdigit c++?

1103


Explain virtual destructor?

1190


What is the best way to take screenshots of a window with c++ in windows?

1049


What is the c++ code?

1147


Is c++ used anymore?

1090


What is searching? Explain linear and binary search.

998


What are the differences between java and c++?

1074


How do you clear a buffer in c++?

958


If dog is a friend of boy, is boy a friend of dog?

981