Initial commit
This commit is contained in:
32
MKR/code.c
Normal file
32
MKR/code.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
double x, power, result;
|
||||
int n, neg_one;
|
||||
|
||||
printf("Input n (must be an integer): ");
|
||||
scanf(" %d", &n);
|
||||
|
||||
printf("Input x (a number with a floating decimal point): ");
|
||||
scanf(" %lf", &x);
|
||||
|
||||
result = 1;
|
||||
neg_one = -1;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
||||
power = pow(x, 2*i + 1);
|
||||
|
||||
neg_one *= -1;
|
||||
|
||||
result *= (power*neg_one) / (2*i + 1);
|
||||
}
|
||||
|
||||
// result_cos *= x;
|
||||
|
||||
printf("Y = %f\n", result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
5
MKR/run.sh
Normal file
5
MKR/run.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
gcc code.c -o code -lm
|
||||
|
||||
./code
|
||||
Reference in New Issue
Block a user