forked from randerson112358/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Integral.c
42 lines (34 loc) · 833 Bytes
/
Integral.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
This program returns the integral of a function in the form of Cx^n
By: randerson112358
*/
# include <stdio.h>
int main(void)
{
char variable[31];
int constant;
int power;
int i;
int d;
int multC = 1;
printf("Input Cx^n, C, LETTER, 2;\n");
printf("C: ");
scanf("%d", &constant);
printf("x: ");
scanf("%s", variable);
printf("n: ");
scanf("%d", &power); // if power + d <= 0, then its a natural log
printf("What integral?\n");
scanf("%d", &d);
if(power < 0) // natural log
{
printf("ln(%s^%d)\n", variable, power);
}
else{
for(i=0; i<d; i++)
{
multC*=(power + i +1);
}
printf("%d/%d * %s^(%d)\n", constant,multC, variable, power + d);}
system("pause");
}