Write a program which reads a positive integer value and shows its divisors.


Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
int main()
{
	int N, i;
	
	do{
	    printf("Enter N: ");
	    scanf("%d",&N);
	}while(N<0);
	
	printf("Divisors of %d:\n",N);
	for(i=1;i<=N; i++)
	    if(N%i==0)
	        printf("%d ",i);
 
	return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Asymptotic Analysis 19