Skip to main content

Program to accept a number and print the factors of that number.

Program to accept a number and print the factors of that number.


CODE

๐Ÿ‘‡

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5.     int n, i;
  6.     printf("Enter a number : ");
  7.     scanf("%d", &n);
  8.     printf("Factors of %d are : ", n);
  9.     for (i = 1; i <= n; ++i)
  10.     {
  11.         if (n % i == 0)
  12.             printf("\n%d ", i);
  13.     }
  14. }

๐Ÿ‘‰Execute๐Ÿ‘ˆ

//OUTPUT