PRETTY DIFF PRETTY DIFF This diff is colored to make it clear what pai indicates things in your output that shouldn This diff is colored to make it clear what part indicates things in your output that shouldn't The - character refers to newlines, so the gre lored to make it clear w gs in your output that s ter refers to newlines, s ove from your output. The - character refers to newlines, so the g need to remove from your output. need to remove from your output. 1 sin (e) - 0.000004 32 sin (145) = 0.57358d sin (150) = 0.500004 sin (155) = 0.42262- sin (160) = 0.34202d 36 sin (165) = 0.258824 37 sin (170 = 0.17365d 38 sin (175) = 0.08716 39 sin (18e) = 0.00000d 33 ----- 3 sin (5) = 0.08716e 4 sin (10) = 0.17365e 5 sin (15) = 0.25882d sin (20) = 0.342024 sin (25) = 0.42262 8 sin (30) = 0.50000d sin (35) = 0.573584 sin (40) = 0.64279e sin (45) = 0.70711 sin (50 = 0.766044 sin (55) = 0.81915d sin (60) = 0.8660324 sin (65) = 0.906314 sin (70 = 0.93969d 34 35 6. 75 80 85 0.96593d 40 41 sin (185) = -0.087165d sin (190) = -0.17365e sin (195) = -0.25882e sin (200) = -0.342024 sin (205) = -0.422624 sin (210) = -0.500004 sin (215) = -0.573587 sin (22e 10 0.98481e 11 42 12 43 0.99619d %3D 13 44 (06 95) 14 45 1.00000d %3D 15 46 16 47 48 -A64279d PRETTY DIFF PRETTY DIFF 0.99619e This diff is colored to make it clear what par This diff is colored to make it clear what par indicates things in your output that shouldn indicates things in your output that shouldn 100 0.98481e %3D The - character refers to newlines, so the gi The character refers to newlines, so theg need to remove from your output. 105 110 115 120 125 130 135 = 0.96593e %3D need to remove from your output. 0.93969d 48 sin (220) = -0.64279d sin (225) = -0.707110d sin (230) = -0.76604d sin (235) = sin (240) = -0.86602d sin (245) = -0.90631d sin (250) = -0.93969d sin (255) = -0.965932 sin (260) = -0.98481e sin (265) 58 sin (270) = -1.000004 %3D 69 sin (320) 70 sin (325) = -0.57358d 71 sin (330 = -0.50000d 72 sin (335) = -0.42262e 73 sin (340) = -0.342024 sin (345) = -0.25882d sin (350) = -0.17365d 76 sin (355) = -0.08716e 77 sin (360 - -ө.00өөө1e -0.64279e 49 0.906314 50 %3D 51 -0.81915e 0.866034 52 %3D 53 74 0.81915e 54 %3D 75 55 0.766045e 56 %3D 57 = -0.99619d 78 0.70711e %3D Enter the value in degree: ad |140 145 79 59 80 ad 0.64279e 60 sin (275) sin (280) = -0.98481d sin (285) = -0.965934 %3D = -0.9961920 81 ad 61 82 0.57358e ad %3D 62 83 ad 63 sin (290) = -0.93969e 84
So I am getting an error when I submit my c++ code. The prompt for the hw was as follows:
Create 2 functions:
1) Degrees2Radians: which has input Degrees, and returns Radians
2) Drawline: which takes two parameters: a character and numRepetitions and prints the character numRepetitions times, followed by a newline
Inside main()
For values between 0 and 360, in 5 degree increments:
calculate and print the value of sin (degrees),
After every 90 degrees, print out a line of 30 dashes (minus signs '-')
Extra information required:
#include <cmath> // for sin function
In order to have the precise format we want:
Put this at the top of main:
cout.setf(ios::fixed);
cout.setf(ios::showpoint); // show decimals even if not needed
cout.precision(5); // show 5 digits to right of decimal
My code:
#include <iostream>
#include <cmath>
using namespace std;
int i, j;
const double PI = 3.141592;
double Degrees2Radians()
{
int degree; // user input for degree
double radian; // to store the value of radians
// input from the user
cout << "Enter the value in degree: ";
cin >> degree;
// converting degrees into radians
radian = degree * (PI / 180);
return radian;
}
// this function will show the character numRepetitions times
void Drawline(char a, int numRepetitions)
{
// in this loop, character is displayed numRepetitions times
for (i = 1; i <= numRepetitions; i++)
cout << a << endl;
}
int main(void)
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(5);
double radian; // to store the value of radians
// in this loop, the values for radians is
// displayed, after every 5 degrees
for (i = 0; i <= 360; i = i + 5)
{
// converting degrees into radians
radian = i * (PI / 180);
// display The result
cout << "sin " << (i) << " = " << sin(radian) << endl;
// in this if, a line of 30 dashes will be
// displayed, after every 90 degree
if (i % 90 == 0 && i > 0)
{
for (j = 0; j < 30; j++)
cout << "-";
cout << endl;
}
}
// calling the functions
Degrees2Radians();
Drawline('a', 5);
}
Below I have attached the error screenshots I received. It seems the bracket needs to be included after sin and then for sin(60),sin(130),sin(185),sin(215),sin(225),sin(255),sin(275)and sin(360) I am getting different results from what the output should be.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images