C++ Program that will be able to ask the user the coefficients of 4 linear equations.

newbie here,

my teacher gave this activity

C++ Program that will be able to ask the user the coefficients of 4 linear equations.

thanks
so what do you need help with?
Here's asking for one value.

1
2
3
4
5
6
7
8
#include <iostream>

int main()
{
  std::cout << "Enter a value";
  int x;
  std::cin >> x;
}
a program

1. Will be able to ask the user the coefficients of 4 linear equations.

Example:
Given a system of linear equation:
A + 2B + 3C + 4D = 5
2A + 3B + 5C +10D = 7
A + B +13C + 5D = -11
2A – B + 5C – 7D = 11

Example display:

Enter the coefficients of equations # 1:
1
2
3
4
5

Enter the coefficients of equation # 2:
2
3
5
10
7

Enter the coefficients of equation # 3:
1
1
13
5
-11

Enter the coefficients of equation # 4:
2
-1
5
-7
11


The Equivalent Matrix is:
1 2 3 4 5
2 3 5 10 7
1 1 13 5 -11
2 -1 5 -7 11
































Last edited on
In other words, you need to ask 20 numbers.

That is where loops do fine. See http://www.cplusplus.com/doc/tutorial/control/

Where to store the values? Into array-like data structure.
http://www.cplusplus.com/doc/tutorial/arrays/
http://www.cplusplus.com/reference/array/array/
http://www.cplusplus.com/reference/vector/vector/
The std::array has syntactic sugar that the plain array does not. Sugar is sweet.
The std::vector has dynamic allocation too.

You do know that there are four equations and five coefficients in each equation. Fixed amount.
std::array or plain array should do fine.
thanks keskiverto,

I will try to do this, any idea for a start is really a big help.

no idea where to start.

thank you
Last edited on
Topic archived. No new replies allowed.