write the program for prime numbers?

Answer Posted / chinnakannasabari

#include <stdio.h>


int main (void)
{
int i, nb, count, test;
test = count = 0;
printf ("enter integer: ");
if (scanf ("%d", &nb) != 1)
return -1;

for (i = 2; i < nb; i++, count++)
if (nb % i == 0)
test = 1;
if (!test)
printf ("%d prime number, number of iterations = %dn",
nb, count);
else
printf ("%d is not a prime number, number of iterations
= %dn", nb,count);
return 0;
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

please explain every phase in the "SDLC" in the dotnet.

2181


Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1510


What is sizeof return in c?

618


What is the heap in c?

646


Explain what is the difference between a free-standing and a hosted environment?

636






what do u mean by Direct access files? then can u explain about Direct Access Files?

1643


I have seen function declarations that look like this

603


What is a shell structure examples?

592


What is the difference between malloc() and calloc() function in c language?

605


Explain the bubble sort algorithm.

647


What is use of #include in c?

601


What is a null string in c?

590


Why static variable is used in c?

559


Tell me what is null pointer in c?

616


What is the difference between array and pointer in c?

582