Nov 15, 2012 at 8:38am UTC
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 :)
Nov 15, 2012 at 9:26am UTC
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
Nov 15, 2012 at 10:06am UTC
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++?
Nov 15, 2012 at 11:32am UTC
please post the code you have so far
Nov 15, 2012 at 12:22pm UTC
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");
}
Nov 15, 2012 at 1:36pm UTC
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 Nov 15, 2012 at 1:36pm UTC