I am currently in an introduction to programming class, and still don't know much. My current assignment is to write a program that returns a table that gives the cosine, sine, and tangent for every 15 angles from 0 to 90. I don't believe my code has any bugs, but the code won't run. I'm not sure if my computer is just too trash or what. Here's the code:
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double ang_deg = 0;
double ang_rad = 0;
while (ang_deg < 91);
{
ang_rad = (ang_deg * M_PI) / 180.0;
cout << setw(7) << "ANGLE" << setw(7) << "SIN" << setw(7) << "COS" << setw(7) << "TAN" << endl;
cout << fixed << setprecision(3);
cout << setw(7) << ang_deg << setw(7) << sin(ang_rad) << setw(7) << cos(ang_rad) << setw(7) << tan(ang_rad) << endl;
ang_deg = 15;
}
return 0;
}
I have had a diagnostics running for about 10 minutes. My other programs have took about 30 seconds.
My IDE and console which should have my table
CodePudding user response:
Here's a bug
while (ang_deg < 91);
should be
while (ang_deg < 91)
Your version is an empty while loop, because the loop is empty ang_deg
never changes and so the loop never terminates. That's why your program seemed not to run (in fact it did run, but it never finished).
Sometimes the smallest things can be errors.