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 are nested functions in c?
ATM machine and railway reservation class/object diagram
What is null character in c?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
Should a function contain a return statement if it does not return a value?
Explain 'far' and 'near' pointers in c.
What is else if ladder?
Can the curly brackets { } be used to enclose a single line of code?
What are the loops in c?
What is default value of global variable in c?
What does do in c?
State the difference between realloc and free.
What is pointers in c with example?
Why functions are used in c?
Is c is a low level language?