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 / suresh kumar

#include<iostream.h>
#include<conio.h>
void main()
{
int n,k,i=1;
cout<<"enter any no to check prime";
cin>>n;
for(i=2;i<n;i++)
{
if(n%i==0)
k=2;
}
if(k==2)
cout<<"the no is not prime"<<endl;
else
cout<<"the no is prime";
getch();
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When does the c++ compiler create temporary variables?

1086


What is the role of copy constructor in copying of thrown objects?

1117


Differentiate between declaration and definition.

1103


What are the general quetions are in DEna bank manager IT/System interviews?

2064


Where Malloc(), Calloc(), and realloc() does get memory?

1102


What is the main purpose of c++?

1107


What is a list c++?

1156


Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

1083


Is atoi safe?

1094


Why Pointers are not used in C++?

1126


Explain the difference between using macro and inline functions?

1182


What is the difference between strcpy() and strncpy()?

1192


What is the latest c++ version?

1153


Explain rtti.

1139


What is the use of bit fields in structure declaration?

1029