Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

check whether a no is prime or not.

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


Please Help Members By Posting Answers For Below Questions

What is a pointer with example?

1154


What is exception handling? Does c++ support exception handling?

976


What are the uses of typedef in a program?

1033


Show the declaration for a static member variable.

956


Is it possible for the objects to read and write themselves?

1061


Write a program to concatenate two strings.

1031


How to declaring variables in c++?

1108


How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?

2276


What is null and void pointer?

999


What are the various storage classes in C++?

1090


How do you declare a set in c++?

914


What is the syntax for a for loop?

1074


What is a memory leak c++?

1063


What are built-in functions? What is the syntax for the definition?

1029


What is conditions when using boolean operators?

1146