Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

find factors of a number in c

#include <stdio.h>
int main() {
    int num, i;
    printf("Enter a positive integer: ");
    scanf("%d", &num);
    printf("Factors of %d are: ", num);
    for (i = 1; i <= num; ++i) {
        if (num % i == 0) {
            printf("%d ", i);
        }
    }
    return 0;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #find #factors #number
ADD COMMENT
Topic
Name
4+5 =