Wednesday

Write a program to input an integer number and check whether it is prime or not.

#include<stdio.h>
#include<conio.h>
void main()
  {
    int n,c=0,i;
    clrscr();
    printf("\nEnter any integer number: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
     if(n%i==0)
      c=c+1;
    }
     if(c==2)
     printf("%d is prime number",n);
     else
     printf("%d is not prime number",n);


     getch();
  }

No comments:

Post a Comment

Rahul-Notes