-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab3.cpp
More file actions
39 lines (31 loc) · 1.3 KB
/
lab3.cpp
File metadata and controls
39 lines (31 loc) · 1.3 KB
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
#include <iostream>
#include <fstream>
#include <cctype>
#include <cmath>
#include <iomanip>
using namespace std;
//function prototype
void printTable(int, int, int, int);
int main() {
//reading file and creating angle variables
ifstream angle("angle.txt");
int ang1, ang2, ang3, ang4;
angle >> ang1 >> ang2 >> ang3 >> ang4;
//call function
printTable(ang1, ang2, ang3, ang4);
return 0;
}
//prints table with each angles sin, cos, and tan
void printTable(int ang1, int ang2, int ang3, int ang4) {
double rad1, rad2, rad3, rad4;
rad1 = ang1 * 3.1416 / 180.0;
rad2 = ang2 * 3.1416 / 180.0;
rad3 = ang3 * 3.1416 / 180.0;
rad4 = ang4 * 3.1416 / 180.0;
//formatting and math
cout << right << setw(5) << "Angle" << right << setw(10) << "Sine" << setw(10) << "Cosine" << setw(10) << "Tangent" << endl;
cout << right << setw(5) << ang1 << right << setw(10) << sin(rad1) << setw(10) << cos(rad1) << setw(10) << tan(rad1) << endl;
cout << right << setw(5) << ang2 << right << setw(10) << sin(rad2) << setw(10) << cos(rad2) << setw(10) << tan(rad2) << endl;
cout << right << setw(5) << ang3 << right << setw(10) << sin(rad3) << setw(10) << cos(rad3) << setw(10) << tan(rad3) << endl;
cout << right << setw(5) << ang4 << right << setw(10) << sin(rad4) << setw(10) << cos(rad4) << setw(10) << tan(rad4) << endl;
}