Answer Posted / waleed
#include<iostream.h>
#include<conio.h>
int prime(int);
void main()
{
clrscr();
int num,x;
cout<<"Enter the no.=";
cin>>num;
x=prime(num);
if(x==1)
{
cout<<"Number is prime";
}
else
{
cout<<"Number is not prime";
}
getch();
}
int prime(int x)
{
int k;
for(int i=2;i<x;i++)
{
if (x%i==0)
{
k=2;
}
}
if (k==2)
return 0;
else
return 1;
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is operator overloading in c++ example?
What is the use of namespace std in C++?
What are mutator methods in c++?
How to access a variable of the structure?
What is a down cast?
What does obj stand for?
What are iterators in c++?
How do you invoke a base member function from a derived class in which you have not overridden that function?
Is c++ an oop?
What is private inheritance?
How do I make turbo c++ full screen?
Can you overload the operator+ for short integers?
What is endl c++?
How will you call C functions from C ++ and vice-versa?
How to defines the function in c++?