Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a C ++ program using the while loop that will create a trig table of Sin

ID: 3826263 • Letter: C

Question

Create a C ++ program using the while loop that will create a trig table of Sin Cos and Tan of an angle. The program should direct the user for input as to the whole number degree increments to calculate the Sin Cos and Tan. For example, it would direct the user to input the increment steps for angles and a user would respond lets say with with 30 degree increments. Again the user decides the degree increments. The output should print to three decimal places. The output would look something like:

Degrees   Sin     Cos    Tan

   0             xxx     xxx      xxx

   30           xxx     xxx      xxx

   60           xxx     xxx      xxx

So the users decides what are the steps in degrees and the program outputs the table.

Explanation / Answer

Answer

// Example program
#include <iostream>
#include <iomanip>
#include <math.h>
#define PI 3.14159265
using namespace std;
int main()
{
double deg=0.0,angle=0.0,x,val,si,co,ta;
cout<<" ----------------------------";
cout<<" Enter angle Increment : ";
cin>>deg;
cout<<" --------------------------------------------------------";
cout<<" Degree Sin Cos tan";
cout<<" -------------------------------------------------------- ";
while(angle<=360&&angle>=0)
{
if(angle>360||angle<0)
break;
x = angle;
val = PI / 180.0;
si = sin( x*val );
co = cos( x*val );
ta = tan( x*val );
cout<<setprecision(3)<<x<<" "<<si<<" "<<co<<" "<<ta<<endl;
angle+=deg;
}
return 0;
}