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