Question
Print The Factor of a Given Number Using C-Program With Comma
Sample TestCase Expected Output
1. 101,2,5,10
2. 121,2,3,5,6,12
Answer
#include <stdio.h>int main() { int num, i; scanf("%d", &num); for (i = 1; i <= num; ++i) { if (num % i == 0) { if(i==1)
printf("%d", i);
else
printf(",%d", i); } return 0;}
Explanation:
What is the factor in math?
Factor, in mathematics, a number or algebraic expression that divides another number or expression evenly—i.e., with no remainder. For example, 3 and 6 are factors of 12 because 12 ÷ 3 = 4 exactly and 12 ÷ 6 = 2 exactly. .This called Factors of a number...
This comment has been removed by a blog administrator.
ReplyDelete