Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
TCS NQT Technical and Managerial Round Interview Questions
Interview Questions and Answers :: Broadcom Ltd

30. Write the program to find prime numbers.

Answer:

int n;
int a=0;
scanf("%d",&a);
n=a;
while (n>2)
{
if(n%2!=0)
{
n=n/2;
if (n>=2)
{
printf("%d is prime number", a);
break;
}
}
else
{
printf("%d is not prime number", a);
break;
}

}

Post Your Answer Here:      Public      Private

Rate This: +1 -0
Report     

Post Your Reply Here:     

Report Error

Report Error

Please Login First Click Here