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
What is implicit conversion/coercion in c++?
Difference between strdup and strcpy?
What are the various situations where a copy constructor is invoked?
Why is main an int?
What are proxy objects in c++?
Differentiate between an array and a list?
Explain virtual destructor?
What is the use of setfill in c++?
Can I have a reference as a data member of a class? If yes, then how do I initialise it?
Explain the difference between class and struct in c++?
Do we have to use initialization list in spite of the assignment in constructors?
How should runtime errors be handled in c++?
Describe delete operator?
What is protected inheritance?
Mention the storage classes in c++.