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 / daljeet singh

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i;
char prime;
prime='Y';
cout<<"\n enter a number";
cin>>n;
for(i=2;i<=n/2;++i)
{
if(n%i==0)
{
prime='N';
break;
}
}
if(n==1)
prime='N';
if(prime=='Y')
cout<<"\n entered number is prime";
else
cout<<"\n not a prime no";
getch();
}

Is This Answer Correct ?    10 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When are exception objects created?

1037


What is c++ runtime?

1067


What is c++ stringstream?

1064


What is operator overloading in c++ example?

1066


Write a program using display() function which takes two arguments.

1022


What are the important differences between c++ and java?

1108


Why is main function important?

1066


What are the uses of typedef in a program?

1050


How to demonstrate the use of a variable?

1068


Can manipulators fall in love?

970


Is empty stack c++?

953


How would you call C functions from C++ and vice versa?

1110


What is an inclusion guard?

1135


Is python written in c or c++?

1119


Is java made in c++?

1020