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

Show the declaration for a static member variable.

1010


How a macro differs from a template?

1182


What will happen if a pointer is deleted twice?

1195


What is the this pointer?

1128


What is conditions when using boolean operators?

1241


What are arrays c++?

1117


Write bites in Turbo c++ Header ("Include") Files.

1274


Write a program to interchange 2 variables without using the third one.

1068


What is the keyword auto for?

1045


What is the use of cmath in c++?

1079


What is the last index number in an array of 100 characters a) 100 b) 99 c) 101

1157


What is a pointer how and when is it used?

1104


Which function cannot be overloaded c++?

1123


Should the member functions which are made public in the base class be hidden?

1036


How would you obtain segment and offset addresses from a far address of a memory location?

1091