Structure and Union
In this example, We will learn a program to find factor of a number. You must have knowledge in following topics before looking this example
Learn C programming directly from mobile. This app includes tutorials with topics, examples and live compiler.
This is the algorithm of this program
Step 1: Start
Step 2: Initialize a variables num
Step 3: Take input from user and store in num
Step 4: Assign i = 1
Step 5: REPEAT this step until u <= num / 2
IF num % i == 0
Increase i by 1
Step 6: End
This is the flowchart of this program
Now, We will see the code to find factor of a number
int num, i;
printf("Enter the number to find the factors of : ");
printf("\nFactors of %d are \n", num);
for (i = 1; i <= num / 2; i++)
if (num % i == 0)
The output of above program is
Enter the number to find the factors of : 12
Factors of 12 are
1 2 3 4 6
Get the latest tutorials, examples and projects updates.
Ads Blocker Detected!!!
We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.
Disable Ad Block
Want Same System