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
Explain how overloading takes place in c++?
If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?
When can I use a forward declaration?
What is one dimensional array in c++?
Explain 'this' pointer and what would happen if a pointer is deleted twice?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
What is a pdb file?
Which c++ operator cannot overload?
What relational operators if statements in c++?
What is a multiset c++?
When one must use recursion function? Mention what happens when recursion functions are declared inline?
Where do I find the current c or c++ standard documents?
What is searching?
Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.
What is tellg () in c++?