how can i solve this problem ???

Write a program to simulate hand-held electronic calculator. Your program should execute as follows:

Step 1: display a prompt and wait for the user to enter an instruction code (a single character):

‘+’ for addition‘-‘ for subtraction‘*’ for multiplication‘/’ for division‘p’ for power‘c’ to clear the current accumulator‘s’ for square root‘l’ for log‘n’ for ln‘q’ for quit

Step 2: (if needed) display a prompt and wait for the user to enter a type float number (which we will call left-operand)

Step 3: (if needed) display a prompt and wait for the user to enter a type float number (which we will call right-operand)

Step 4: display the accumulated result at any point during processing and repeat steps 1 through 3 using a GOTO statement (no loops in this assignment).

Use a separate function enter_code to prompt the user for instruction code and to ensure that a valid code is entered. Also, use a separate function enter_operand for the entry of the left-operand and the right-operand. Finally, use another function compute to perform the indicated operation. (unless q was entered).

Ok this wont be that difficult.In the main you got to take the input from the user(what he wants to do) and than use switch(choice) or else you can use nested if else statements.Depending on the choice the user makes each choice would invoke the required function from main.For example
----------------------------------------------------------
int i;
switc(i)
{
case 1: assuming case 1 is addition
int sum = add (x,y)
.
.
}
----------------------------------------------------------
So go about this way and you obviously will have to define each function aditon ,subtraction,multiplication and so on.
I suggest you write something and post it coz no one's going to code for you.Let me know if it helped

Well, does it work as you want? If not then it's not right. If it does then it is right.
Have you tried compiling it?
Did you get any errors?

Programming is very much about doing stuff yourself. If you're so stuck that you can't even plug code into a compiler then I would suggest you're way out of your depth already and should consider getting some extra tuition outside class otherwise you're never going to make it.

Oh I see. You can't. The way you've done it - taking numeric input for the operation the user wants to do - means you can only accept numerical commands. But the assignment explicitly says you should get + for add, - for subtract and so on. So instead of int which_one; cin >> which_one; you need to declare which_one to be a char so that the user can enter a character command.

Also note the assignment states "Use a separate function enter_code to prompt the user for instruction code" and mentions another function as well - if you don't do this then after all the work you've done you'll still fail it.

One thing I'm not clear on is why left_operand *and* right_operand are needed. On a handheld calculator typically you use the current accumulator and a single new number, so you would enter + to add, then enter a new number and press =, and that would add the new number to the accumulator. Perhaps you could ask what should happen if the user enters +: does the program ask for two numbers, or does it ask for one and add the number to the accumulator? If it asks for two numbers and + adds those, what does it do with the number in the accumulator - does the new result overwrite that?

Well there you go. Surprised myself; I don't normally do homework, but watching you struggle with this is too painful. This is the first pass - I haven't compiled this code so I don't know if there are any silly errors (there probably are). You'll have to figure out what to #include to make the function calls strchr, log, pow etc work OK but I imagine those will be in your course notes somewhere.

I've resolved the question about the accumulator by having the result overwrite the previous value. If you want to add up a few numbers then you'll need to keep re-entering the current result, e.g. to add 2,3,5,2 you need to do 2+3=5, 5+5=10, 10+2=12. This is not like a calculator where you would usually do 2+3+5+2= and that would display 12 with the interim results displayed as you enter each option.