Hello there this is a c++ program that I need help with it Page Warmup exercises
ID: 3881895 • Letter: H
Question
Hello there this is a c++ program that I need help with itPage Warmup exercises-we will discuss the following Declaring integers int, short, long, unsigned, char and outputting using . correct format specifiers such as $%d, %u %c, %ld, %lu . Outputting integers in base ten, octal and hexadecimal . integer divided by integer and flaot divided by integer . arithmetic operators +,,, 1,0 and negative sign . precedence and associativity of these operators 1st parentheses 2nd negative 3rd multiple and divide 4th add and subtract All of these are performed associtively left-to-right math functions provided by C library math.lh o sqrt(x) o log (x) Ithis is the natural log in the C library o sin (x), cos (x) o asin(x) o fabs (x) Lab 3 We are all familiar with angles. Recall angle measurements radians and degrees have been discussed in detail in your Trigonometry/Precalculus course. One radian equals 57.295770 degrees. One degree equals 0.017453333 radians (a) prompt the user to input an angle in radian measure and output the angle in degree measure. Now the user to input an angle in degree measure and output the angle in radian measure. (b) Consider a right triangle as illustrated yr ITP
Explanation / Answer
a) //Program for radian to degree conversion
#include <iostream>
using namespace std;
int main()
{
int deg;
double rad; // variables for storing radian and degree values
cout << "Enter the radian value: ";
cin >> rad; //entering radian value through keyboard
deg= rad * 180 / 3.14159265; //conversion from radian to degree
cout <<"degree value is"<<deg; // displaying degree value
cout << "enter degree value " << deg << endl;
cin>>deg; //entering degree value through keyboard
rad=deg * 180 / 3.14159265; //conversion from degree to radian
cout << "radian value is"<<rad; //displaying radian value
return 0;
}
b)Program to calculate opposite length and angles theta,alpha
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int hypotenuse,adjacent,rightAngle=90,theta,alpha,result;// variables for storing values
cout<<"enter hypotenuse and adjacent values"<<endl;
cin>>hypotenuse>>adjacent; //entering adjacent and hypotenuse values
opposite=(hypotenuse*hypotenuse)-(adjacent*adjacent);// calculating length of opposite side
cout<<"length of opposite is"<<endl;
cout<<opposite;
result=opposite/hypotenuse;
theta=asin(result);// calculating theta value using sine inverse function
alpha=180-(rightAngle+theta);// calculating alpha value
cout<<"theta value is"<<theta<<"°"<<endl;
cout<<"alpha value is"<<alpha<<"°"<<endl;
return 0;
}
c) Program to display sine series
#include<iostream>
#include<iomanip>
void main()
{
int i, n;
float deg,j,rad;
cout<<" Enter the value for degree : "; //enter degree value
cin>>deg;
cout<<" Enter the value for n : "; //enter n=7 to stop series at 7
cin>>n;
cout<<"degree value"<<deg<<"°"<<endl;
rad=deg*3.14159/180; //conversion from degree to radian
cout<<"radian value"<<rad<<endl;
cout<<"Sx="<<rad;
/* Loop to display the Sine series */
for(i=3,j=2;i<=n;i=i+2,j++)
{
if(j%2==0)
{
cout<<"-"<<"("<<rad<<<<"/"<<i<<"!)";
}
else
{
cout<<"+"<<"("<<rad<<i<<"/"<<i<<"!)";
}
}
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.