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 the word you will use when defining a function in base class to allow this function to be a polimorphic function?
What is public, protected, private in c++?
What is function overloading c++?
What is the difference between mutex and binary semaphore?
What is the use of setfill in c++?
What is a Default constructor?
Is c++ slower than c?
Which operator cannot overload?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
What do you understand by pure virtual function? Write about its use?
How do you compile the source code with your compiler?
What is meant by entry controlled loop?
What is difference between rand () and srand ()?
What is pair in c++?
what is upcasting in C++?