f(x) multiple

can someone tell me how to input the variable in the calculation without error ?
example : if we input 5x and 4x, then we want to multiple the 5x with 4x, and the program can show us the result for 5x*4x = 20x square (20 x2).

so i want that the program can multiple the combination between the number and the variable, can someone help me ? i dont know how to make the program.. everytime i tried, it was error..

thankyouu before :)
imo it's easiest for you to use a function with 2 input parameters.
first parameter = value
second parameter = variable

for the square values just multiply
for the variables use some ifs or switch cases
what include do you use?
i need like f(g(x)), so if fx=2x then gx = 3x, the answer is 6x, but how can i code that in c++?
please post the code you have so far
it's only the basic, and i still confuse how to make the coding --"

#include <iostream>
#include <string>

using namespace std;

int main()
int a;
std::string g;
cout << "Pilihan perkalian fungsi:"<< endl;
cout << "1.Perkalian 2 fungsi" << endl;
cout << "2.Perkalian 3 fungsi" << endl;
cin >> a;
if (a=1)
{cout << "Ketikan fungsi yang akan dikalikan, fungsi 1 : " << endl;
cin >> g;
if( g == "f")
std::string f="f";
std::cout << f << "x" << std::endl;
std::string c = f + " x";
std::cout << c << std::endl;

cout << "fungsi 2 : " << endl;
std::string b="b";
std::cout << b << "x" << std::endl;
std::string d = b + " x";
std::cout << d << std::endl;

system ("pause");
first of all use code tags, when posting source code

if you use "using namespace std", there is no need to write std::....
"if (a=1)" this is wrong. you probably mean if(a==1)

and i dont get your output ;)
Last edited on
Topic archived. No new replies allowed.