Composite Number solution using c language--programming_info problem 20

Composite Number


#include<stdio.h>
int main()
{
    int i,n,factor;
    printf("Enter the number:");
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
         if(n%i==0) 
         {
             factor=i;/*finds the largest proper divisor*/
         }
    }
    if(factor>1) 
    {
          printf ("The number is a composite number!");
    }
    else 
    {
          printf ("This is not a composite number!");
    }
    return 0;
}
Share:

No comments:

Post a Comment

Translate

Recommended platforms

  1. codechef
  2. hackerrank
  3. codeforces
  4. leetcode
  5. hackerearth

Popular Posts

programming_info. Powered by Blogger.

Blog Archive

Recent Posts

other platforms

  • geeks for geeks
  • w3schools
  • codepen
  • skillshare
  • udemy

Pages

reader support Support