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

What is c++ and its uses?

1224


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

6403


What is the default access level?

1064


Write about the various sections of the executable image?

969


What is the header file for setw?

1124


How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?

975


What is a multiset c++?

1144


what are the characteristics of Class Members in C++?

1041


Why do we use structure in c++?

1072


What are the comments in c++?

983


What is split a string in c++?

1182


What is the default width for ouputting a long integer using the insertion operator?

1233


What is a breakpoint?

1022


Does std endl flush?

1034


Will c++ be replaced?

1041