Answer Posted / rajan maheshwari
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int a,c=0,i=2;
cout<<"Enter A Number = ";
cin>>a;
while(i<=a/2)
{
if(a%i==0)
{c=0;
break;}
else
{i++;
c=1;
}}
if(c==1||a==2||a==3)
cout<<"\nPrime Number";
else
if(a==1)
cout<<"\nNeither Prime Nor Composite";
else
cout<<"\nNot a Prime Number";
getch();
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is this weird colon-member (" : ") syntax in the constructor?
Explain the difference between using macro and inline functions?
Is c++ the hardest language?
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
Describe about storage allocation and scope of global, extern, static, local and register variables?
Which software is best for c++ programming?
Write a program to add three numbers in C++ utilizing classes.
what is C++ objects?
Define a nested class.
Is the declaration of a class its interface or its implementation?
What does it mean to declare a member function as virtual?
How do we balance an AVL Tree in C++?
Explain "const" reference arguments in function?
How do you establish a has-a relationship?
You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()