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 / swapnil

/*To check whethere Entered no. is PRIME or NOT*/
#include<iostream.h>
#include<conio.h>
main()
{
int num,i;
clrscr();
cout<<"Enter the any no.="<<"\n";
cin>>num;
for(i=2;i<=num;i++)
{
if(num%i==0)
{
break;
}
}
if(i==num)
{
cout<<"The number entered is a
PRIME no.";
}
else
{
cout<<"The number entered is NOT a
PRIME no.";
}
getch();
}

Is This Answer Correct ?    74 Yes 41 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain this pointer?

1077


What you know about structures in C++?

1102


Describe the syntax of single inheritance in C++?

1087


Why main function is special in c++?

1144


Name the implicit member functions of a class.

1094


Why is main an int?

1006


What is a stack c++?

1025


Write a recursive program to calculate factorial in c++.

1097


What is the difference between c++ and turbo c++?

1217


What is the full form nasa?

1121


What is the default access level?

1082


What is algorithm in c++ programming?

1139


find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.

2569


What is the return value of the insertion operator?

1139


which of the following is not an secondary constant a) array b) real c) union

1816