Advertisement
Alx09

tabelare

Mar 13th, 2022
963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. void tabelare(double a, double b, int n, double(*functie)(double val)) {
  4.     double step = (b - a) / n;
  5.     while (a <= b) {
  6.         printf("f(%f)= %f ", a, functie(a));
  7.         a += step;
  8.     }
  9. }
  10.  
  11. int main() {
  12.     tabelare(-10, 10, 20, fabs);
  13.     tabelare(-10, 10, 20, cos);
  14.     tabelare(-10, 10, 20, sqrt);
  15.     scanf_s("%*c"); // sa nu se inchida consola
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement