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

How does java differ from c and c++?

1042


What is time h in c++?

1184


What are the different types of comments allowed in c++?

1026


What does it mean to declare a member variable as static?

1117


What do you mean by public protected and private in c++?

1112


What is the difference between a reference and a pointer?

1182


Can I make ios apps with c++?

1097


Can there be at least some solution to determine the number of arguments passed to a variable argument list function?

1061


Is c++ still in demand?

1200


Do you know the problem with overriding functions?

1170


Is python written in c or c++?

1201


Is it possible to provide special behavior for one instance of a template but not for other instances?

1173


What is c++ flowchart?

1457


Write a program to find the Factorial of a number

1117


What do you mean by early binding?

1130