Hoaxblog.com

Everything is hoax!

Pages:

  • About

Categories:

  • Apache (6)
  • backup (1)
  • cache (2)
  • Cpanel/WHM (11)
  • ddos (1)
  • exam (1)
  • file hosting (2)
  • General (11)
  • Hosting (1)
  • It’s me (2)
  • linux (1)
  • Linux Shell (14)
  • Make Money Online (2)
  • Mysql (2)
  • mysqldump (1)
  • php (1)
  • Programming (3)
  • proxy (1)
  • Reseller (1)
  • SEO (1)
  • Servers (21)
  • VPN (1)
  • Windows (6)
  • wordpress (1)

Archives:

  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • October 2007
  • May 2007
  • April 2007

Blogroll

  • Free Rapidshare Downloads

Meta:

  • Register
  • Login
  • Valid XHTML
  • XFN
  • WordPress


C Programme to get the roots of Bionomial Equation(s)

There is no standard library files in C Programming which can do complex number calculations. According to bionomial theoram there can be Complex and Real roots. But as C doesn’t bother with Complex numbers so, we need to use real number canculation to get the complex root at a+bi form.

Here is a short example what i have done:

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
#include <stdio.h>
#include <math.h>
#include <conio.h>
void main()
{
double a,b,c,d,e,f,g;
clrscr();
printf("Please type the numbers");
scanf("%lf%lf%lf",&a,&b,&c);
 
d=(b*b)-(4*a*c);
 
if (d>=0) {
	if (d==0) {
	printf("It has one real root\n");
	e=(-b+sqrt(d))/(2*a);
	printf("Here is the root: %.2lf\n",e);
		} else {
	printf("It has real roots\n");
	e=(-b+sqrt(d))/(2*a);
	printf("First Real Root: %.2lf\n",e);
	e=(-b-sqrt(d))/(2*a);
	printf("Second Real Root: %.2lf\n",e);
	}
} else {
	printf("It has complex roots\n");
	f=-d;
	e=(-b/(2*a));
	g=(sqrt(f)/(2*a));
	printf("First Complex Root: %.2lf+%.2lfi\n",e,g);
	printf("Second Complex Root: %.2lf-%.2lfi\n",e,g);
	}
getch();
 
}

If you enter some value for this programme like 1 3 1 for a,b and c according to a Quadratic or Bionomial Equation then the result will be with two real number outputs. If you enter 1 2 1 for a,b and c then the result will be one real number output as at that time both roots will be equal. And if you enter 1 1 1 then the result will be with two complex numbers.

Happy Coding! :)

This entry was posted on Thursday, April 19th, 2007 at 2:49 pm and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply


© Copyright by Hoaxblog.com