/*********************************************************** vertex-form.ch Vertices This program completes the square of a quadratic and uses this information to find the location of the quadratic's vertex. ************************************************************ 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 a, b, c, factor1, factor2, completethesquare, totaladded, factor, combine, xvertex, yvertex; //Get values printf("enter a, the coefficient of x^2: "); scanf("%lf", &a); printf("enter b, the coefficient of x: "); scanf("%lf", &b); printf("enter c, the constant: "); scanf("%lf", &c); //factor 'a' out of the first and second term factor1 = a/a; factor2 = b/a; printf("\n%.2lf*x^2 + %.2lf*x + %.2lf", a, factor2, c); //complete the square and subtract completethesquare = (factor2/2)*(factor2/2); totaladded = completethesquare*a; printf("\n%.2lf*x^2 + %.2lf*x + %.2lf + %.2lf - %.2lf", a, factor2, completethesquare, c, totaladded); //factor the binomial factor = factor2/2; combine = c - totaladded; printf("\n%.2lf*x^2 + %.2lf^2 + %.2lf", a, factor, combine); //identify the vertex xvertex = -factor; yvertex = combine; //Display results printf("The vertex is located at (%.2lf,%.2lf)", xvertex, yvertex);