C Language | Prime Numbers

Thursday, 6 December 2012

In numbers, there are those that can be divided with different other integers and those that are only limited to the integer itself and number one (1). That kind of numbers are known as the Prime Numbers. Prime numbers can only be divided by the number one (1) or the prime number itself.

Sometimes, it can be difficult for us to recognize prime numbers specially when the numbers are large. That's why I made a program that evaluates a number and tells us if the number is a prime number or not. In this program, I used looping statements and If else statements to make the program more stable. Check out the sample code below.

     1:  
   2:  #include<stdio.h>
   3:  #include<conio.h>
   4:   
   5:  main()
   6:  {
   7:        int input, num=0, div, count, count2,x;
   8:        printf("Enter how many counts: ");
   9:        scanf("%d",&count);
  10:        
  11:        if(count>3000){
  12:        printf("You have exceeded the maximum input of 3000");
  13:        getch();
  14:        return 0;
  15:        }
Related Posts Plugin for WordPress, Blogger...