Program to accept a number and print its prime factors

//Program to accept a number and print its prime factors
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,k=2,j;
  clrscr();
  printf("Enter the number\n");
  scanf("%d",&n);
  while(k<n)
  {
   if(n%k==0)
   {
     n=n/k;
     printf("%4d",k);
       if(n%k==0)
       printf("%4d",k);
   }
   k++;
  }
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

3 comments: