C Program To Find Factors Of A Number

 

C Program To Find Factors Of A Number

In this example, you will learn to Find Factors Of A Number


Example :

Enter Any Number To Find Factors 12

Factors Of The Given Number Are = 1, 2, 3, 4, 6, 12

How Program Works ??

  • Input number from user. Store it in variable say number.
  • Run a loop Example (i = 1; i <= Number; i++)
  • To check factor if(number % i == 0) then i is a factor of num.
  • If i is a factor of number then print i.

Logic ??

Factor of any number is a  number which exactly divides the number into a whole number without any remainder.


Code For  "Find Factors Of A Number".


/* Author --> HARSH PATEL */

#include <stdio.h>
int main()
{
  int i, Number;

  printf("\nEnter Any Number To Find Factors \n");
  scanf("%d", &Number);

  printf("\nFactors Of The Given Number Are = \n");
  for (i = 1; i <= Number; i++)
   {
     if(Number%i == 0)
        {
		 printf(" %d  ", i);
		}
   }

  return 0;
}

Output-1

Enter Any Number To Find Factors
12

Factors Of The Given Number Are =
 1   2   3   4   6   12
Output-2

Enter Any Number To Find Factors
25

Factors Of The Given Number Are =
 1   5   25
Output-3

Enter Any Number To Find Factors
100

Factors Of The Given Number Are =
 1   2   4   5   10   20   25   50   100
Output-4

Enter Any Number To Find Factors
10

Factors Of The Given Number Are =
 1   2   5   10
Output-5

Enter Any Number To Find Factors
234

Factors Of The Given Number Are =
 1   2   3   6   9   13   18   26   39   78   117   234
Output-6

Enter Any Number To Find Factors
1

Factors Of The Given Number Are =
 1

😊 Some Image Of Program To Find Factors Of A Number
 





OUTPUT



  • Now Program End Without Any Error.
🖥️ Learn Programming Languages Free In Our Website Coding With Harsh 
👨‍🎓 5000+ Happy Visitor 👩‍🎓
🌐 Free Programing Examples In WebsitCoding With Harsh 

  • If Any Query Regarding Programs, Website Or More Details Email Us On Contact@CodingWithHarsh.gq





Popular posts from this blog

C Program To Print Hello World

Declare And Initialize Two Character Constants And Output It To User

C Program To Calculate Profit Or Loss