efrei/programmation-c-cpp/tp5/fonction_f.c

28 lines
386 B
C
Raw Normal View History

2021-11-29 09:28:10 +01:00
/* f(x) = sin(x) + ln(x) - sqrt(x) */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float fonction_f(int);
int main() {
float f;
printf("x\tf(x)\n");
for (int i = 1; i <= 10; i++) {
f = fonction_f(i);
printf("%d\t%g\n", i, f);
}
return 0;
}
float fonction_f(int x) {
float f;
f = sin(x) + log(x) - sqrt(x);
return f;
}