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


Please Help Members By Posting Answers For Below Questions

Is struct oop?

780


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.

2550


How do I create a directory? How do I remove a directory (and its contents)?

867


Once I have used freopen, how can I get the original stdout (or stdin) back?

845


Explain void pointer?

800


List some basic data types in c?

769


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

1645


What does a pointer variable always consist of?

876


What are c preprocessors?

925


What is the difference between memcpy and memmove?

784


Is it possible to use curly brackets ({}) to enclose single line code in c program?

1061


What is a char in c?

764


Explain how can I remove the trailing spaces from a string?

821


What are linker error?

849


what is bit rate & baud rate? plz give wave forms

1726