C Program to find the prime numbers below a given number.

by Nideesh C on April 18, 2011 · 0 comments

in C Programming




#include<stdio.h>
void main()
{
int i, prime, lim_up, n;
clrscr();
printf(“nnt ENTER THE UPPER LIMIT…: “);
scanf(“%d”, &lim_up);
printf(“nnt PRIME NUMBERS ARE…: “);
for(n=1; n<lim_up; n++)
{
prime = 1;
for(i=2; i<n; i++)
if(n%i == 0)
{
prime = 0;
break;
}
if(prime)
printf(“nnttt%d”,n);
}
getch();
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program to find the prime numbers between a given range
  2. C program to generate and print prime numbers in a given range. Also print the number of prime numbers
  3. C program to check whether a given number is prime or not and output the given number with suitable message
  4. C Program for Armstrong numbers
  5. C program to read N integers (zero, +ve and -ve) into an array A and to a) Find the sum of negative numbers b) Find the sum of positive numbers and c) Find the average of all input numbers Output the various results computed with proper headings

Leave a Comment

Previous post:

Next post: