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 parts of c program?
Is fortran still used in 2018?
Tell me with an example the self-referential structure?
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
What is the role of && operator in a program code?
What is #pragma statements?
Explain what is the benefit of using an enum rather than a #define constant?
Explain the difference between getch() and getche() in c?
Explain why can’t constant values be used to define an array’s initial size?
What does %c mean in c?
What is spark map function?
Are comments included during the compilation stage and placed in the EXE file as well?
regarding pointers concept
What does & mean in scanf?
Does sprintf put null character?