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
How can a string be converted to a number?
Explain what is the difference between a free-standing and a hosted environment?
What is volatile variable in c?
why return type of main is not necessary in linux
How to implement a packet in C
What is the general form of function in c?
How many bytes are occupied by near, far and huge pointers (dos)?
Explain how can I open a file so that other programs can update it at the same time?
How can you tell whether a program was compiled using c versus c++?
What is the concatenation operator?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
Difference between malloc() and calloc() function?
What does calloc stand for?
What is cohesion in c?
What is spaghetti programming?