When asked this: Your program should then ask the user to enter two angles in de
ID: 3666768 • Letter: W
Question
When asked this:
Your program should then ask the user to enter two angles in degrees. For this assignment you may either ask two separate questions or ask one question and have the user enter two values. The first angle the user provides should take the place of u in the above equations, and the other v. ( For simplicity the logarithmic expressions will also be evaluated using the same u and v. )
Your program should read the user input into long doubles variables named uLongDouble and vLongDouble. You should then copy them into doubles named uDouble and vDouble, and into floats named uFloat and vFloat.
How do you write the user input in c++?
Explanation / Answer
#include<iostream>
#include<math.h> //for mathematical calculation
using namespace std;
int main(){
//declare variables
long double uLongDouble,vLongDouble;
double uDouble,vDouble;
float uFloat,vFloat;
//ask the user to enter the first angle
cout<<"Enter first angle in degree :";
//store the input in declared variable
cin>>uLongDouble;
//ask the user to enter the second angle
cout<<"Enter second angle in degree :";
//store the input in declared variable
cin>>vLongDouble;
//print the result
cout<<"Values in long double format : "<<uLongDouble<<" And "<<vLongDouble<<endl;
cout<<"Copying to double from long double "<<endl;
uDouble=uLongDouble;
vDouble=vLongDouble;
cout<<"Values in double format : "<<uDouble<<" And "<<vDouble<<endl;
cout<<"Copying to float from long double "<<endl;
uFloat=uLongDouble;
vFloat=vLongDouble;
cout<<"Values in float format : "<<uFloat<<" And "<<vFloat<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.