How to find Factors of a Number using C-Programing - Learn Engineering

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

Breaking

Saturday, May 30, 2020

How to find Factors of a Number using C-Programing

Question

The Factor of a Given Number Using C-Program

Sample TestCase Expected Output

1. 101 2 5 10


2. 121 2 3 4 6 12


Answer

#include <stdio.h>
int main() 
{
    int num,  i ;
    scanf("%d", &num);
    for (i = 1; i <= num; ++i)
     {
        if (num % i == 0) 
        {
            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...

3 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging.. teknisk analys

    ReplyDelete
  3. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. lära sig teknisk analys

    ReplyDelete