Skip to content

Commit 6848713

Browse files
committed
bisection
1 parent 9660987 commit 6848713

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

Diff for: bisectionmethod.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<stdio.h>
2+
#include<math.h>
3+
4+
double function(double x)
5+
{
6+
double ans;
7+
ans = x*x*x - 6*x*x + 11*x - 6;
8+
return ans;
9+
}
10+
11+
double bisection(double a, double b)
12+
{
13+
double c=1;
14+
15+
while (function(c) != 0)
16+
{
17+
c = (a+b)/2;
18+
19+
if (function(c)<0)
20+
{
21+
a = c;
22+
}
23+
else if (function(c)>0)
24+
{
25+
b = c;
26+
}
27+
}
28+
return c;
29+
}
30+
31+
int main()
32+
{
33+
double m,n;
34+
scanf("%lf%lf",&m,&n);
35+
printf("%lf\n",bisection(m,n));
36+
return 0;
37+
}

Diff for: commandlineargumentpractice.c

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include<stdio.h>
2+
3+
int main(int argc, char *argv[])
4+
{
5+
printf("%s\n", argv[2]);
6+
printf("n %d\n",argc);
7+
return 0;
8+
}

0 commit comments

Comments
 (0)