Write a C Program to check if the number is prime number or not

Write a program in the C programming language to check if the inputted number is a prime number or not. In this program for loop is used to create numbers from 2 to n-1 to check if they are divisible by n or not and if any of them is divisible then the control is transferred outside the for loop by using the break statement and the result is printed in negative. Below is the code of the program –

/* C Program to check if number is prime number or not */

void main()
     int n,i,ct=0,rd=0;

     printf("Enter any number \n");


            printf("\n %d is prime number",n);
            printf("\n %d is not prime number",n);


Input – 23
Output – 23 is a prime number

yashan has written 69 articles

18 thoughts on “Write a C Program to check if the number is prime number or not

    1. Lo attesa per tanto tempo questa poesia,e nel rileggerla dal profondo dell’anima, ad ogni verso montava,con l’andamento di una incalzante melodia, la passione e l’orgoglio.Grazie Pietro, finissimo cantore della terra amata, ancora una volta ci hai regalato un’intensissima emozione.All’anonimo: moltissimi se ne vanno, molti ritornano, nessuno dimentica.

    2. I have two questions: How long does it take to create a collection from inception to the final product. and secondly, Which of your collections would you say is your favorite?Thank you for the great website links. I have just added a few to my favorites!How wonderful that you two work together. (BTW, you could pass for twins!)

    3. http://www./ says:

      een goede comment eigenlijk, met uitstekende voorbeelden erbij. Zou zomaar een reactie van een reaguurder hier kunnen zijn (ikzelf heb helaas een ban). Eigenlijk vind ik de comments daaronder veel bizarder. Wat een stel afgestompte mongolen zijn het ook op KLOL:Koala: @wakkervrak; ?dat is mijn antwoord. Misschien eens naar je hart luisteren…Johan Bosman: @Wakkervrak: waar woon je, waar werk je en wie betaald (sic) jou?

  1. The holiday happens to coincide with the end-of-the-season for
    many of the Island’s young summer employees and brings on a last chance for partying hearty on Mackinac Island. People will say just about anything to get you out to their property to see a horse, in the hopes of selling you something else they might have. Morgan is a breed of horse very much desired by the horse community as they entertain all riding disciplines.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>