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.

Answers were Sorted based on User's Feedback



check whether a no is prime or not...

Answer / 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

check whether a no is prime or not...

Answer / paramjeet singh

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,c;
printf("enter any number\n");
scanf("%d",&i);
printf("you have entered=%d\n",i);
for(c=2;c<=i-1;c++)
{
if(i%c==0)
printf("this no.is not a prime number");
}
printf("this is prime number");
getch();
}

Is This Answer Correct ?    2 Yes 0 No

check whether a no is prime or not...

Answer / rama

#include<stdio.h>
main()
{
int n,i,r;
clrscr();
printf("Enter the positive integer value");
scanf("%d",&n)
i=2;
step1:
if(i<=sqrt(n))
{
r=n%i;
if(r==0)
{
printf("%d is not a prime",n);
goto end;
}
}
else
{
i++;
goto step1;
}
printf("%d is prime number",n);
end:
printf(" ");
}

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More C++ General Interview Questions

What are the uses of pointers?

0 Answers  


What is the operator in c++?

0 Answers  


Is c++ fully object oriented?

0 Answers  


How would you use qsort() function to sort an array of structures?

0 Answers  


What is c++ good for?

0 Answers  


Is sorted c++?

0 Answers  


How many standards of c++ are there?

0 Answers  


what is data abstraction in C++?

0 Answers  


Is swift faster than go?

0 Answers  


"How will you merge these two arrays? Write the program Array: A 1 18 22 43 Array: B 3 4 6 20 34 46 55 Output Array: C 1 3 4 6 18 20 22 34 43 46 55"

9 Answers   College School Exams Tests, HCL,


When should overload new operator on a global basis or a class basis?

0 Answers  


Does c++ vector allocate memory?

0 Answers  


Categories