using namespace std;
#include<iostream>
int main()
{
cout<<"www.moznum.blogspot.com"<<endl<<endl;
int i,n,c=0;
cout<<"Enter the number: ";
cin>>n;
cout<<endl<<"The Factors are: "<<endl;
for(i=1;i<=n;++i)
{
if(n%i==0)
{
cout << i <<endl ;
c++;
}
}
cout<<endl<<"And. . . "<<endl;
if(c==2)
cout<<n<<" is a Prime Number";
else
cout<<n<<" is Composite Number. !!";
}
- C++ program which takes base and height as input and gives the area of a rectangle
- How to write a C++ program that prints the factors of the number and also prints that a number is a prime number or a composite number by taking the number from the user.
- C++ Program to Print multiplication tables of a number by taking input to the desired number.
- How to write a C++ program that prints the factors of the number and also prints that a number is a prime number or a composite number by taking the number from the user.
- C++ Program to Print multiplication tables of a number by taking input to the desired number.
You can also search this topic by this:
A prime number is a whole number greater than 1, which is only divisible by 1 and itself. First few prime numbers are : 2 3 5 7 11 13 17 19 23
ReplyDelete2 is the only even Prime number. Prime number program in C++. Every prime number can represented in form of 6n+1 or 6n-1, where n is natural number. 2, 3 are only two consecutive natural numbers which are prime too.
Sir, could you make a code for composite triangle. I hope you can help sor
ReplyDelete