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
Is register a keyword in c?
What is the use of a conditional inclusion statement in C?
Why can’t we compare structures?
What is the purpose of scanf() and printf() functions?
What does a pointer variable always consist of?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
What is the difference between procedural and declarative language?
find the sum of two matrices and WAP for it.
Why do we use pointer to pointer in c?
formula to convert 2500mmh2o into m3/hr
How many keywords are there in c?
Can we compile a program without main() function?
What are the uses of a pointer?
What is function in c with example?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?