Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is the difference between formatted&unformatted i/o functions?

1003


What 'lex' does?

1100


What is function what are the types of function?

945


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

1146


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

1067


Why is this loop always executing once?

998


write a program to display all prime numbers

1911


Write a program to check prime number in c programming?

1028


how to build a exercise findig min number of e heap with list imlemented?

2017


how to write optimum code to divide a 50 digit number with a 25 digit number??

3203


Is it possible to initialize a variable at the time it was declared?

1172


what are # pragma staments?

1997


Why structure is used in c?

1107


What is type qualifiers?

1076


Is printf a keyword?

1155