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
Write a program to swap two numbers without using the third variable?
Explain About fork()?
What is structure padding in c?
What are the 3 types of structures?
What is union in c?
How can I read and write comma-delimited text?
When do we get logical errors?
Write the Program to reverse a string using pointers.
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
Why is c so popular?
Explain how do you view the path?
How can I remove the trailing spaces from a string?
What is int main () in c?
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
What is a good data structure to use for storing lines of text?