pls help with my school project... its a program that get the factors of an algebriac expression... my problem is the output... when i input a = 1, b = 5, c =6 the output is correct but when i input a = 5, b = 26, c = 24 the output is (4x+6)(1x+5) the correct output must be (5x+6)(1x+4)..

here's my wrong work.. pls help me correct it.. i've been working it for 2 weeks and i still can't make it right..

Code:
#include<stdio.h>
void factor(int a,int b,int c);
void factor1(int a,int b,int c,int d);

main()
{
    int a,b,c;
    clrscr();
    printf("enter the value of a,b,c for the equation ax^2 + bx + c:\n");
    printf("a = ");
    scanf("%d",&a);
    printf("b = ");
    scanf("%d",&b);
    printf("c = ");
    scanf("%d",&c);
    printf("the equation now is %dx^2 + %dx + %d",a,b,c);
    factor(a,b,c);
    getch();
}

void factor(int a,int b, int c)
{
    float sum;
    int i=0,start,fctr1;
    start = a * c;
    do
    {
       i++;
       if(start%i==0){
       fctr1=start/i;
       sum=fctr1+i;}
    }while(sum>b);
    if(sum==b){
       printf("\nThe equation is factorable and\nthe factors are: ");
       factor1(fctr1,a,c,i);}
    else
       printf("\nThe equation is not factorable!!");
}

void factor1(int a,int b,int c,int d)
{
     float w,y,l,i,n,e;
     int x=0,z=0;
     do
     {
    do
    {
      x++;
      w=a/x;
      n=w*x;
    }while(n<a);
    do
    {
      z++;
      y=d/z;
      e=y*z;
    }while(e<d);
    l=x*z;
    i=y*w;
     }while((l<c)&&(i>b));
     if((w==y)&&(z==x))
    printf("(%.0fx+%i)^2",w,z);
     else
     printf("(%.0fx+%i)(%.0fx+%i)",w,z,y,x);
}

Last edited by shabbir; 27Feb2010 at 18:23.. Reason: Code blocks