Write a program to accept any number and display the factors of the number. Also display the sum of the factors.
Home
/
Write a program to accept any number and display the factors of the number. Also display the sum of the factors
Write a program to accept any number and display the factors of the number. Also display the sum of the factors.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
#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;
Explanation:
Answer:
Write a program to accept any number and display the factors of the number. Also display the sum of the factors.