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 == in programming?
What do you understand by pure virtual function? Write about its use?
What problems might the following macro bring to the application?
What is the difference between prefix and postfix versions of operator++()?
what is Member Functions in Classes?
What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h
What are the sizes and ranges of the basic c++ data types?
Which bit wise operator is suitable for putting on a particular bit in a number?
What is class definition in c++ ?
Differentiate between declaration and definition.
What is a list c++?
Does c++ vector allocate memory?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
What does the ios::ate argument do?
What happens if a pointer is deleted twice?