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
Explain the use of #pragma exit?
Explain what is the use of a semicolon (;) at the end of every program statement?
What does c mean?
What is the purpose of sprintf() function?
Is null always defined as 0(zero)?
Why is c so important?
What is difference between union and structure in c?
What is dynamic memory allocation?
What is the difference between a function and a method in c?
please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics
What is structure packing in c?
Why pointers are used?
Why n++ execute faster than n+1 ?
How do you determine the length of a string value that was stored in a variable?
Explain what are the __date__ and __time__ preprocessor commands?