Jim

first commit

File mode changed
No preview for this file type
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int varmas[4]; // because 4 vars j,k,l,m, n
double a,b,h,x;
int getvars (){
printf ("Input J:\n");
scanf("%i", &varmas[0]);
printf ("Input K:\n");
scanf("%i", &varmas[1]);
printf ("Input L:\n");
scanf("%i", &varmas[2]);
printf ("Input M:\n");
scanf("%i", &varmas[3]);
printf ("Input N:\n");
scanf ("%i", &varmas[4]); //is N
printf ("Input A:\n");
scanf ("%lf", &a);
printf ("Input B:\n");
scanf ("%lf", &b);
printf ("%i %i %i %i %i\n", varmas[0], varmas[1], varmas[2], varmas[3], varmas[4]);
printf ("%f %f\n", a, b);
return 0;
}
double f (double x){
return x * (1.0 - x) - 1.0 / 8.0;
}
int main (){
int i;
double *func_val;
double max;
getvars();
h = b - a / (double)varmas[4] - 1.0;//calculate fixed step
func_val = malloc (sizeof (double) * varmas[4]);
for (i=0; i < varmas[4]; i++){
x = a + i * h;
func_val[i] = f(x);
printf ("x value: %f, function in that point: %f\n", x, func_val[i]);
}
free (func_val);
return 0;
}
... ...