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 c++
Explain Memory Allocation in C/C++ ?
Is it possible for the objects to read and write themselves?
Are vectors faster than arrays?
Do vectors start at 0?
Explain operator overloading.
Which is better c++ or java?
What is virtual methods?
Explain what is class definition in c++ ?
Can we overload operator in c++?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
What are c++ data types?
What is virtual function? Explain with an example
Can we define a constructor as virtual in c++?
What is the use of c++ programming language in real life?