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

Is register a keyword in c?

631


What is the use of a conditional inclusion statement in C?

598


Why can’t we compare structures?

814


What is the purpose of scanf() and printf() functions?

721


What does a pointer variable always consist of?

663






The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration

630


What is the difference between procedural and declarative language?

648


find the sum of two matrices and WAP for it.

630


Why do we use pointer to pointer in c?

595


formula to convert 2500mmh2o into m3/hr

494


How many keywords are there in c?

588


Can we compile a program without main() function?

630


What are the uses of a pointer?

679


What is function in c with example?

627


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

1904