How to show the result in the form of a table in this task?

Create a program for calculating the function F (x) on the interval [a, b] with step h. The result is presented in the form of a table, the first column of which is the value of the argument, the second is the corresponding value of the function.

#include <iostream> #include <cmath> using namespace std; int main () { double a, b, h; cout << "Введите a: " , cin >> a; cout << "Введите b: " , cin >> b; cout << "Введите шаг h: ", cin >> h; for (double x = a; x <= b; x += h) cout << x << "\t" << tan (x / 2) + 2 * cos (x) << endl; return 0; } 
  • When inserting the program code, select it with the mouse and press the 101 010 button, then the formatting will be correct. - Nicolas Chabanovsky
  • What is the question? Your code already displays the results of calculations in the form of a table, where in the first column is the value of the argument, and in the second column is the value of the function. - Nicolas Chabanovsky
  • Hmm, it displays in my line, can you post a screenshot? - scor
  • What for?! Just run your code in Visual Studio. "<< endl" - this provides a newline. - Nicolas Chabanovsky
  • so it displays the result in a row, and there must be columns with values - scor

1 answer 1

 $ g++ sample.cc -o sample && ./sample Введите a: 1 Введите b: 2 Введите шаг h: 0.5 1 1.62691 1.5 1.07307 2 0.725114 
  • eem, I apologize for the question, but where to write it? - scor