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
Is struct oop?
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
How do I create a directory? How do I remove a directory (and its contents)?
Once I have used freopen, how can I get the original stdout (or stdin) back?
Explain void pointer?
List some basic data types in c?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
What does a pointer variable always consist of?
What are c preprocessors?
What is the difference between memcpy and memmove?
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What is a char in c?
Explain how can I remove the trailing spaces from a string?
What are linker error?
what is bit rate & baud rate? plz give wave forms