Write your question here.
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 43 44 45 46 47
|
#include <iostream>
using namespace std;
int main()
{
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
cout << "Enter your x^2 coefficient. If there is no coefficient beside it enter 1." << "\n" << "This means the a in standard form ax^2+bx+c:";
cin >> a;
cout << "Now enter your second x coefficient:";
cin >> b;
cout << "\n" "Finally, enter your c value:" << "\n";
cin >> c;
cout << "Now i will solve." << "\n";
if(a>1 || a<1)
{
b/a = d;
c/a = e;
d/2 = f;
f*f = g;
c-g = h;
cout << "Your solution is:" << "(" << "x+" << f << ")" << "^2 +" << h;
}
else
{
b/2 = i;
i*i = j;
c-j = k;
cout << "Your solution is;" << "(" << "x+" << i << ")" << "^2 +" << k;
}
system("PAUSE");
return 0;
}
|
Compiling: main.cpp
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp: In function 'int main()':
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:29: error: lvalue required as left operand of assignment
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:30: error: lvalue required as left operand of assignment
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:31: error: lvalue required as left operand of assignment
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:32: error: lvalue required as left operand of assignment
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:33: error: lvalue required as left operand of assignment
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:40: error: lvalue required as left operand of assignment
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:41: error: lvalue required as left operand of assignment
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:42: error: 'k' was not declared in this scope
C:\CPP_Programs\Minigame\Converting from Standard To Vertex Form\main.cpp:45: error: 'system' was not declared in this scope
Process terminated with status 1 (0 minutes, 1 seconds)
9 errors, 0 warnings
Hello guys! Here is my code and warmings I am getting. I am an aspiring (beginner) programmer who am just trying to have some fun by having a program for quadratic conversion. Ill give you an example of how it works:
Lets say I have 2x^2 + 4x + 8
I would divide x^2 by 2 = x^2
I would divide 4 by 2 (b in my program): 4/2= 2
Then I would divide 8 by 2 (resulting variable e in my program) 8/2 = 4
Then I would square the result of dividing 4/2 = 2. So 2^2=4
Then I would plug in the result of 4/2 = 2 into (x+(2))^2
Then subtract the 4 from 8, 8-4 = 4
Final answer: (x+2)^2 + 4.
This is the result I would want from my program.
How could I adjust my program to get it to get something like this result?
Why do i need to have 1value as the left operand of an assignment if the user will input numbers for the variables?
Thank you (all) so much in advance! I really appreciate your help!