The Factor of a Given Number Using C-Program With Comma - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Saturday, June 6, 2020

The Factor of a Given Number Using C-Program With Comma

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...

Follow Us For More...

1 comment: