-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQuad_library.cpp
72 lines (71 loc) · 3.34 KB
/
Quad_library.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// *****************************************************************************
// Program name: "QuadraticFormula". This program reads the three coeffeicients
// (a, b, c) of a quadratic equation (a)x^2 + (b)x + (c) = 0 through the
// standard input device. It then calculates the
// roots of said equation and outputs the result to the standard output device.
// One root is returned. If there are no real roots, 0 is returned.
// Copyright (C) 2021 Sean Javiya.
//
// This file is part of the software QuadraticFormula
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// *****************************************************************************
//
//
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Author information
// Author name: Sean Javiya
// Author email: [email protected]
//
// Program information
// Program name: QuadraticFormula
// Programming languages: One driver module in C, one module in X86, two
// library modules in C++, and one bash file
// Date program began: 2021-Feb-19
// Date of last update: 2021-Feb-27
// Date of reorganization of comments: 2021-Feb-27
// Files in this program: Quad_library.cpp, Quadratic.asm, Second_degree.c,
// isfloat.cpp, run.sh
// Status: Finished.
// The program was tested extensively with no errors in (Tuffix) Ubuntu 20.04
// Purpose
// This program is a library of three basic print functions.
// This program is called by Quadratic, which will calculate the real roots of
// a quadratic equation. This program will also be submit (for credit) for an
// assignment conducted during my graduate studies program.
// This file
// File name: Quad_library.cpp
// Language: C++
// Max page width: 132 columns (this file was not optimized for printing)
// Compile:
// gcc -c -Wall -m64 -no-pie -o Quad_library.o Quad_library.cpp
// Link:
// g++ -m64 -no-pie -o QuadraticFormula.out Second_degree.o isfloat.o Quad_library.o Quadratic.o -std=c11
//
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <cstdlib>
extern "C" void show_no_root();
extern "C" void show_one_root(double root);
extern "C" void show_two_root(double root1, double root2);
void show_no_root() {
printf("This equation has no real roots.\n");
}
void show_one_root(double root) {
printf("The root of this equation is:\n %8.12lf\n", root);
}
void show_two_root(double root1, double root2) {
printf("The roots of this equation are:\n %8.12lf and %8.12lf\n", root1, root2);
}