Data Structure
 Networking
 RDBMS
 Operating System
 Java
 MS Excel
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP
- Selected Reading
 - UPSC IAS Exams Notes
 - Developer's Best Practices
 - Questions and Answers
 - Effective Resume Writing
 - HR Interview Questions
 - Computer Glossary
 - Who is Who
 
C/C++ Program for Finding the vertex, focus and directrix of a parabola?
Here we will see how to find the vertex, focus directrix of a parabola using C or C++ program. To get these parameters we need the general equation of a parabola. The general formula is −
? = ??2 + ?? + ?
The values of a, b and c are given.

The formula for the vertex −

The formula for the focus −

The formula for the Directrix - y −

Example
#include <bits/stdc++.h> using namespace std; void getParabolaDetails(float a, float b, float c) {    cout << "The vertex: (" << (-b / (2 * a)) << ", " << (((4 * a * c) - (b * b)) / (4 * a)) << ")" << endl;    cout << "The Focus: (" << (-b / (2 * a)) << ", " << (((4 * a * c) - (b * b) + 1) / (4 * a)) << ")" << endl;    cout << "y-Directrix:" << c - ((b * b) + 1) * 4 * a << endl; } main() {    float a = 10, b = 3, c = 4;    getParabolaDetails(a, b, c); }  Output
The vertex: (-0.15, 3.775) The Focus: (-0.15, 3.8) y-Directrix:-396
Advertisements