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 a c++ map?
What are the 2 main types of data structures?
Is there any function that can skip certain number of characters present in the input stream?
What is c++ runtime?
What is the limitation of cin while taking input for character array?
If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?
What is a static element?
Explain differences between alloc() and free()?
Do class declarations end with a semicolon?
What are the benefits of c++?
What do you mean by global variables?
. If employee B is the boss of A and C is the boss of B and D is the boss of C and E is the boss of D. Then write a program using the Database such that if an employee name is Asked to Display it also display his bosses with his name. For eg. If C is displayed it should also display D and E with C?
In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h
What is the identity function in c++? How is it useful?
Explain the isa and hasa class relationships. How would you implement each?