write a program to count and display divisor of a number by using whileloop....
Answers
Answered by
5
home
TUTORIAL
EXAMPLES
search
C Program to Display Factors of a Number
Example to find all factors of an integer (entered by the user) using for loop and if statement.

To understand this example, you should have the knowledge of following C programming topics:
C Programming Operators
C if...else Statement
C Programming for Loop
This program takes a positive integer from the user and displays all the positive factors of that number.
Example: Factors of a Positive Integer
#include <stdio.h> int main() { int number, i; printf("Enter a positive integer: "); scanf("%d",&number); printf("Factors of %d are: ", number); for(i=1; i <= number; ++i) { if (number%i == 0) { printf("%d ",i); } } return 0; }
Output
Enter a positive integer: 60 Factors of 60 are: 1 2 3 4 5 6 10
Similar questions
Social Sciences,
6 months ago
CBSE BOARD XII,
6 months ago
Biology,
6 months ago
English,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago