C Online Compiler
Example: C Program to Find Factors of a Number using Function
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find Factors of a Number using Function #include <stdio.h> // This function will display the factors void Factors(int x) { printf("\nThe factors of the %d are: ", x); for (int i = 1; i <= x; ++i) { if (x % i == 0) { printf("%d ", i); } } printf("\n"); } // It's the driver function int main() { int x; printf("-----Enter the positive integer number-----\n"); scanf("%d", &x); Factors(x); return 0; }
90
Output
Clear
ADVERTISEMENTS