Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Sunday, April 4, 2010

To input an integer and print whether it is a prime number or not.

Dell D600 Laptop 1.6ghz 40gb DVD/CDRW B Grade Includes Genuine XP Professional restore cd!Write a program in C to input any positive integer and to print whether it is a prime number or not.
Toshiba Satellite L505-GS5037 TruBrite 15.6-Inch Laptop (Black)

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main( )
{
int i, m, nd;

nd=0;
printf("Enter a positive integer\n");
scanf("%d", &m);
for(i=1; i<=m; i++)
{
if(m % i = = 0)
nd++;
}
if(nd ==2)
printf("%d is a prime number\n", m);
else
printf("%d is not a prime number\n",m);

}

M810 Watch Phone with 2 Stylus Pens

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP