Online Examination System for all learner!!! coming soon..

C : Program to calculate the prime factors of a numbers.

Program to calculate the prime factors of a numbers.


#include<stdio.h>
#include<conio.h>
main()
{
        int x,n;
        printf("Enter a number :");
        scanf("%d",&n);
        prime_factors(n);
}
int prime_factors(int n)
{
        int i=1,k;
        while(i<=n)
        {
                if(n%i==0)
                {
                        k=check_prime(i);
                        if(k!=0)
                                printf("%d ",k);
                }
                i++;
        }
}
int check_prime(int n)
{
        int i=1;
        int c=0;
        while(i<=n)
        {
                if(n%i==0)
                        c++;
                i++;
        }
        if(c==2)
                return n;
        else
                return 0;
}

C Programming Online Test 1

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...