Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to determine entered number is prime or not

Posted By: Aimee Williams     Category: C Programming     Views: 7659

Write a program to determine entered number is prime or not

Code for Program to determine entered number is prime or not in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
    int n,j=0,i,z=0;
    clrscr();

    printf("\n Please Give The Value of N:  ");
    scanf("%d",&n);

    for(i=2;i<=9;i++)
    {
        if(i!=n && n%i==0)
            z=z+1;
    }
    if(z==0)
        printf("\n %d IS PRIME NUMBER ",n);
    else
        printf("\n %d IS NOT PRIME NUMBER ",n);
    getch();
}



************************* OUTPUT *************************************

Please Give The Value of N:  13


    13 IS PRIME NUMBER


Please Give The Value of N:  9


   9 IS NOT PRIME NUMBER


***********************************************************************
  
Share: 


Didn't find what you were looking for? Find more on Program to determine entered number is prime or not Or get search suggestion and latest updates.

Aimee Williams
Aimee Williams author of Program to determine entered number is prime or not is from Stockton, United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!