Integers are any of the natural numbers (positive or negative) including zero, with no decimal places, and are used to represent whole numbers.
A factor is a divisor, it is one of two or more whole numbers that can be exactly divided into another whole number.
/* Find factors. ANSI C. Stanley Garvey 21/10/2010 */ #include <stdio.h>/* All include files before main function. */ main () { int quota, divisor; /* Declare variables. */ /*promt the user for an integer */ printf("please input number to find its factors.: "); scanf ("%d","a); /* brute force loop: check all values of divisor less than integer */ for (divisor = 1; divisor <= quota; divisor++) { if (quota%divisor == 0) /* Is divisor a factor? */ printf(" %d is a factor of %d\n",divisor, quota); } /* end brute force loop */ return(0); /* Politely return a zero (no errors)*/ }Example program output:
please input number to find its factors.: 12 1 is a factor of 12 2 is a factor of 12 3 is a factor of 12 4 is a factor of 12 6 is a factor of 12 12 is a factor of 12Next: Count the number of factors in a whole number.
Related: Print formatting. For loop.
