Object:-Write a Program to display factors of a number
int number, i;
printf("Enter a positive integer: ");
printf("Factors of %d are: ", number);
for(i=1; i <= number; ++i)
if (number%i == 0)
Enter a positive integer: 25
Factors of 25 are: 1 5 25
- In the program, a positive integer entered by the user is stored in variable number.
- The for loop is iterated until i <= number is false. In each iteration, whether number is exactly divisible by i is checked (condition for i to be the factor of number) and the value of i is incremented by 1.