program that solves two linear equations in two variables

program that solves two linear equations in two variables

Page 1 of 1

11 Replies - 11431 Views - Last Post: 31 March 2009 - 02:40 PM Rate Topic: -----

#1 m_s_n1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-November 07

program that solves two linear equations in two variables

Posted 26 March 2009 - 06:13 AM

In this program you are asked to write a program that solves two linear equations in two variables.
The program should ask a user to enter the equations as follows:


as this

Posted Image

http://up111.arabsh..../8st7teq04q.jpg

i wait you


:)

This post has been edited by m_s_n1988: 26 March 2009 - 07:31 AM


Is This A Good Question/Topic? 0
  • +

Replies To: program that solves two linear equations in two variables

#2 bodom658  Icon User is offline

  • Villiage Idiom
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,123
  • Joined: 22-February 08

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 06:43 AM

Do you need help with something?

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 m_s_n1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-November 07

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 07:19 AM

View Postbodom658, on 26 Mar, 2009 - 05:43 AM, said:

Do you need help with something?

[rules][/rules]

Thank you my friend

I do not know the policy of this site

I want you to give me the idea to solve this program
Was This Post Helpful? 0
  • +
  • -

#4 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 07:21 AM

How would you solve the equation non-programmatically?
Was This Post Helpful? 0
  • +
  • -

#5 m_s_n1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-November 07

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 12:32 PM

View Postbsaunders, on 26 Mar, 2009 - 06:21 AM, said:

How would you solve the equation non-programmatically?



i want idea


pleaaaaaaaaaaaaaase
Was This Post Helpful? 0
  • +
  • -

#6 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 01:08 PM

Do you know how to solve two linear equations mathematically?
Was This Post Helpful? 0
  • +
  • -

#7 Notorion  Icon User is offline

  • D.I.C Regular

Reputation: 35
  • View blog
  • Posts: 378
  • Joined: 17-February 09

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 02:32 PM

well, it's simple to do mathematically, and once you have that, you should have it as a cake walk in programming.
Here is a link to teach you how to solve those, and hopefully give you ideas on how to accomplish your task.
Also, google "solve two linear equations with two unknown"

My personal preference is to "solve by substitution"

View this link for an explanation
http://answers.yahoo...10025002AAWpEtk
Was This Post Helpful? 0
  • +
  • -

#8 m_s_n1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-November 07

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 02:35 PM

View Postbsaunders, on 26 Mar, 2009 - 12:08 PM, said:

Do you know how to solve two linear equations mathematically?



l know but how i can use the way here
Was This Post Helpful? 0
  • +
  • -

#9 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 02:38 PM

Can you post the way here?
Was This Post Helpful? 0
  • +
  • -

#10 m_s_n1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-November 07

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 02:57 PM

View Postbsaunders, on 26 Mar, 2009 - 01:38 PM, said:

Can you post the way here?


2x + 3y = 6

x + y = 4 *2

//////////////////////////////

2x + 3y = 6

2x+2y=8 *-1

///////////////////////


2x + 3y = 6
+
-2x-2y=-8
________________________________
0 -y=-2

so x=6
Was This Post Helpful? 0
  • +
  • -

#11 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: program that solves two linear equations in two variables

Posted 26 March 2009 - 04:01 PM

x + y = d
y = d - x

///////////////////////////////////////////////////

Solve for x:

ax + by = c
ax + b(d - x) = c
ax + bd - bx = c
ax - bx = c - bd
x(a - b) = c - bd
x = c - bd / (a - b)

///////////////////////////////////////////////////

Solve for y:

ax + by = c
by = c - ax
y = c - ax / b




int main()
{
	int a, b, c, d;
	int x, y;

	a = 2;
	b = 3;
	c = 6;
	d = 4;

	x = (c - (b * d)) / (a - b); // x = c - bd / (a - b)
	y = (c - (a * x)) / b; // y = c - ax / b

	cout << "The solution of " << a << "x+" << b << "y=" << c
		 << " and x+y=" << d << " is " << "x=" << x << " and "
		 << "y=" << y << endl;

	return 0;
}

This post has been edited by bsaunders: 26 March 2009 - 04:08 PM

Was This Post Helpful? 0
  • +
  • -

#12 m_s_n1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-November 07

Re: program that solves two linear equations in two variables

Posted 31 March 2009 - 02:40 PM

View Postbsaunders, on 26 Mar, 2009 - 03:01 PM, said:

x + y = d
y = d - x

///////////////////////////////////////////////////

Solve for x:

ax + by = c
ax + b(d - x) = c
ax + bd - bx = c
ax - bx = c - bd
x(a - b) = c - bd
x = c - bd / (a - b)

///////////////////////////////////////////////////

Solve for y:

ax + by = c
by = c - ax
y = c - ax / b




int main()
{
	int a, b, c, d;
	int x, y;

	a = 2;
	b = 3;
	c = 6;
	d = 4;

	x = (c - (b * d)) / (a - b); // x = c - bd / (a - b)
	y = (c - (a * x)) / b; // y = c - ax / b

	cout << "The solution of " << a << "x+" << b << "y=" << c
		 << " and x+y=" << d << " is " << "x=" << x << " and "
		 << "y=" << y << endl;

	return 0;
}

thank u my friend


i try now :wub:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1