adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to print the all prime factors of a given number.

Write a program in C to print the all prime factors of a given number.

#include<stdio.h>
#include<conio.h>
  void main()
   {
    int i,n;
        clrscr();
    printf("Enter a no.:-");
    scanf("%d",&n);
    printf("Prime factor=1");
    i=2;
    while(n>1)
      {
        if(n%i==0)
       {
             printf("x%d",i);
            n/=i;
  }
      else
          i++;
     }
    getch();
   }

Output:-




Post a Comment

0 Comments