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
What are the 4 types of functions?
Why static is used in c?
What is the use of the function in c?
What are actual arguments?
What is integer constants?
Explain low-order bytes.
What are the different types of control structures?
How can you invoke another program from within a C program?
How to delete a node from linked list w/o using collectons?
What are nested functions in c?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What are identifiers and keywords in c?
Why do we use c for the speed of light?