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
why programs in c are running with out #include
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
Write a program to print all permutations of a given string.
What are volatile variables in c?
what do you mean by enumeration constant?
What is the use of putchar function?
What is include directive in c?
what type of questions arrive in interview over c programming?
Difference between MAC vs. IP Addressing
Why is python slower than c?
What is a lookup table in c?
Explain how can I convert a number to a string?
What is a char in c?
What is 02d in c?
Why c is faster than c++?