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 is the difference between formatted&unformatted i/o functions?
What 'lex' does?
What is function what are the types of function?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
Why is this loop always executing once?
write a program to display all prime numbers
Write a program to check prime number in c programming?
how to build a exercise findig min number of e heap with list imlemented?
how to write optimum code to divide a 50 digit number with a 25 digit number??
Is it possible to initialize a variable at the time it was declared?
what are # pragma staments?
Why structure is used in c?
What is type qualifiers?
Is printf a keyword?