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