Thursday, 11 September 2014

List the prime numbers below 200 in C Language With Example


C Language Program for finding the list of prime numbers below 200. This code is all about prime number calculation. There will be a lot of possibilities between the numbers 1 to 200. Source code of this C tutorial is given below,


PRIME NUMBERS BELOW 200 IN C
List prime numbers below 200 in C is used to display all the prime number values from one to two hundred by looping statement and conditional statement. If the particular number is satisfies to the condition then, print the value else ignore it.




C CODE SNIPPET:
Q: How to write a c program to find prime numbers below 200?

//Header files
include <stdio.h>
include <conio.h>
 
void main()
{
    //Program variables
    int cn,cn1,temp,num=200,p_flag=0;
 
    clrscr(); //Function to clear previous output
 
    for(cn=2;cn<num;cn++) //Looping statement
    {
        for(cn1=2;cn1<(cn/2);cn1++)
        {
            if(number%cn==1//Conditional statement
            {
                p_flag=1;
                break;
            }
        }
        if(p_flag==1)
            printf("%d-->",cn);
    }
 
    getch();
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.