write the program for prime numbers?
Answer Posted / kiran kumar maharana
#include<iostream.h>
#include<conio.h>
int prime(int);
void main()
{
int n;
cout<<"enter a no.";
cin>>n;
int x;
x=prime(n);
if(x==1)
cout<<"prime";
else
cout<<"not a prime no.";
}
int prime(int n)
{
int i,count=0;
if(n<2)
{
return 0;
}
else
{for(i=2;i<n;i++)
{
if(n%i==0)
{
count++;
}
}
if(count>=1)
{
return 0;
}
else
return 1;}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
what value is returned to operating system after program execution?
What is calloc()?
What is a double c?
5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.
Explain how are portions of a program disabled in demo versions?
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
Do character constants represent numerical values?
Explain how can I read and write comma-delimited text?
Process by which one bit pattern in to another by bit wise operation is?
Is multithreading possible in c?
What is character constants?
Can the “if” function be used in comparing strings?
what is the structure pointer?
Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250
Explain how do you use a pointer to a function?