In: Computer Science
. Assume that a double variable named alpha contains the value of an angle in radians. Compose a C++ statement that will display the sine of the angle so that it occupies 12 positions on the screen and displays 3 digits after the decimal point.
#include <iostream>
#include<cmath>
#include <iomanip>
int main() {
//delcaring variavel to store radians
double alpha = 20;
std::cout << "OUTPUT: \n\n";
//fixing the precision of the floating value.
std::cout.precision(3);
//setw(int n) is used to give a width of n spaces.
//setfill(char c) is used to fill the remaing spaces by charcater c.
std::cout << std::setfill (' ') << std::setw (12); //setting width of 12 charcater spaces in the line
std::cout << sin(alpha); //printing this value, all remaing spaces before this will be filled by setfill().
}
IF THERE IS ANYTHING THAT YOU DO NOT UNDERSTAND, OR NEED MORE HELP THEN P-LEASE MENTIN IT IN THE COMMENTS SECTION,