![]() |
how can i solve this problem ???
Write a program to simulate hand-held electronic calculator. Your program should execute as follows:
‘-‘ 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
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). |
Re: how can i solve this problem ???
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 |
Re: how can i solve this problem ???
Thnx.
If I want to use nsted if can u give me an example from one of them ? |
Re: how can i solve this problem ???
Thnx.
If I want to use nsted if can u give me an example from one of them ? |
Re: how can i solve this problem ???
main()
{ int choice; printf("enter 1 for addition,2 for subtraction............") if(choice==1) { int sum = add(x,y); .. . } else if(choice ==2) { int diff = sub(x,y); . . } else if { . } ----------------------------------------------------------------- and so on.You can also google "syntax of if-else" for more help.Hope that was helpful |
Re: how can i solve this problem ???
Thnx :)
|
Re: how can i solve this problem ???
is this right ?
if it is wrong can u correct it so i can do the complite it :D Code:
|
Re: how can i solve this problem ???
> is this right ?
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. |
Re: how can i solve this problem ???
in VB i can make it
|
Re: how can i solve this problem ???
Code:
#include <iostream>what is goto statement ? and how can i write c,q,ln ? |
| All times are GMT +5.5. The time now is 11:59. |