/*********************************************************** perfect-square.ch Factoring This program factors an expression into (x+c)^2 if it fits the pattern otherwise tells that it does not fit ************************************************************ Copyright 2014 SoftIntegration Inc. http://www.softintegration.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ***********************************************************/ //Initialize variables double coeff, constant; //Get values printf("what is the coefficient of x? "); scanf("%lf",&coeff); printf("what is the constant? "); scanf("%lf",&constant); //calculate and display factored expression if possible if (sqrt(constant) == (coeff / 2)) printf("factored expression: (x+%lf)^2\n",sqrt(constant)); else printf("this equation does not fit the pattern\n");