A
A
Adhol2018-03-04 11:05:33
C++ / C#
Adhol, 2018-03-04 11:05:33

Plotting a function in C language?

Good afternoon, tell me how to plot a function graph as simply as possible using the C language?

#include <stdio.h>
#include <math.h>

int main()
{
  float x, y, z, step;
  printf("input x:\n");
  scanf("%f", &x);
  printf("Input y:\n");
  scanf("%f", &y);
  printf("input step:\n");
  scanf("%f", &step);
  printf("result:\n");
  for(int i = 0; i < 32; i++)
  {
    z = (sin(x)+cos(y))/(cos(x)-sin(y))*tan(x*y);
    printf("%.2f\t %f\n", x, z);
    x += step;		
  }
}

As a result, to get something as close as possible to a graph from Excel:
5a9ba82c11315920922107.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2018-03-04
@zagayevskiy

I think you should use gnuplot.
ndevilla.free.fr/gnuplot

R
res2001, 2018-03-04
@res2001

Switch from a console application to a window application, for example, the simplest window on Qt and display the graph already in the graphics window using Qt. The graph can be drawn manually, or you can use any ready-made Qt widgets, they are.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question