Prime Factorisation in C : Well I have been assigned to do the prime factorisation but the problem is i have hard-coded it till prime numbers:2,3,5,7,11,13,19 and i want to make it general...

    #include <stdio.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>

    int main()
    {

        void prime(int flag,int num);
        int num,flag,i,div;
        printf("Enter your number: ");
        scanf("%d",&num);
        flag=1;
        prime(flag,num);


        return 0;
    }

    void prime(int flag, int num)
    {
        void factor(int num,int i);
        int sq,i,square; 
        sq=abs(sqrt(num));

        if (num==2)
              flag=1;  
        else
            for (i=2;i<=sq;i++)
         {
             if (num%i==0)
             {
                 flag=0;
                 break;
             }
             else
                 flag=1;
         }
        if (flag==1)
            printf("\n%d is a prime number",num);
        else
        {
            printf("\n%d is not a prime number\n",num);
            factor(num,i);
        }
    }      

    void factor(int num,int i)
    {
        for (i=2;i<=num;i++)
        {
            again:
            if(num%i==0)
           {
               num=num/i;
               printf("%d ",i);
               if (num!=2||3||5||7||11||17||19)
                   goto again;              
           }   
        }

    }

P.S.:Try to make it as simpler as possible.