Answer Posted / m.shanmuga sundaram,rjnsoftwar
void main()
{
int primeNo;
int i;
bool isPrime = false;
printf("Enter a number to check prime or not\n");
scanf("%d",&primeNo);
for(i = 2; i <= primeNo / 2; i++)
{
if(primeNo % i == 0)
{
isPrime = true;
break;
}
}
if(isPrime)
printf("The number is a prime number %
d\n",primeNo);
else
printf("The number is not a prime number %
d\n",primeNo);
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is a pointer with example?
What is exception handling? Does c++ support exception handling?
What are the uses of typedef in a program?
Show the declaration for a static member variable.
Is it possible for the objects to read and write themselves?
Write a program to concatenate two strings.
How to declaring variables in c++?
How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?
What is null and void pointer?
What are the various storage classes in C++?
How do you declare a set in c++?
What is the syntax for a for loop?
What is a memory leak c++?
What are built-in functions? What is the syntax for the definition?
What is conditions when using boolean operators?