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 is the purpose of clrscr () printf () and getch ()?
Explain the use of #pragma exit?
What is putchar() function?
What are the disadvantages of c language?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
How can a process change an environment variable in its caller?
When should a far pointer be used?
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
what is the difference between 123 and 0123 in c?
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
Can you return null in c?
List some of the dynamic data structures in C?
What is the difference between %d and %i?
What is p in text message?
What is a newline escape sequence?