Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scratchyourbrain/6cc5d509901e708726f7 to your computer and use it in GitHub Desktop.
Save scratchyourbrain/6cc5d509901e708726f7 to your computer and use it in GitHub Desktop.
C program to Display Factors of a Number
#include <stdio.h>
int main()
{
int n,i;
printf("Enter a positive integer: ");
scanf("%d",&n);
printf("Factors of %d are: ", n);
for(i=1;i<=n;++i)
{
if(n%i==0)
printf("%d ",i);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment