Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
Author |
Message |
Z #1 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
Hey guys.. need help badly because I still can't figure out how to start! I guess I gonna fail my C programming.. I just started.. and the calculator needs to use either switch functions or if,else functions... here is the code I type..- maybe you guys can guide me through? Email me pls! #include<stdio.h> #include<stdlib.h> #include<conio.h> #include<math.h> void mainmenu(void); void submenu_arith(void); file://void submenu_trigo(void); file://void submenu_log(void); file://float arifuncs() void main() { int x; while(1) { printf("\t\t\t\t\n\n\nWeLComE"); printf("\t\t\t\t\n\n\n\n1.Arithmetic"); printf("\t\t\t\t\n2.Trigonometric"); printf("\t\t\t\t\n3.Logarithm"); printf("\t\t\t\t\n0.Quit"); printf("\t\t\t\t\nEnter Ya Choice Dude: "); scanf("%d", &x); if(x==0) break; file://what happens when 0 is entered printf("Bye !"); if(x==1) {return submenu_arith()} file://what happens when 1 is entered } void submenu_arith() int x; while(1) { printf("\t\t\t\t\n\n\nArithmethic Menu); printf("\t\t\t\t\n\n\n1.+?"); printf("\t\t\t\t\n\n\n2.-?"); printf("\t\t\t\t\n\n\n3./?"); printf("\t\t\t\t\n\n\n4.*?"); printf("\t\t\t\t\n\n\n5.Back to Main Menu"); printf("\t\t\t\t\n\n\n6.Quit!"); scanf("%d", &x); if(x==0)break; } }
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Z #2 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
remove the no!!!spam from the email address ! Thanks!
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Bart v Ingen Schen #3 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
[comp.lang.c++ removed from newsgroups] Quote:
>Hey guys.. >need help badly because I still can't figure out >how to start! I guess I gonna fail my C programming.. >I just started.. and the calculator needs to use >either switch functions or if,else functions... >here is the code I type..- >maybe you guys can guide me through?
What is your exact problem? First you tell us you don't know how to start and then you provide the beginnings of a program, so you seem to have answered your own question. Quote: >Email me pls!
Sorry, no private consultation here. Quote: >#include<stdio.h> >#include<stdlib.h> >#include<conio.h> >#include<math.h> >void mainmenu(void); >void submenu_arith(void); >file://void submenu_trigo(void); >file://void submenu_log(void); >file://float arifuncs() >void main()
In the language C main is defined as: int main() or int main(int argc, char*argv[]) Use only one of these forms, so int main() Quote: >{ > int x; > while(1) > { > printf("\t\t\t\t\n\n\nWeLComE"); > printf("\t\t\t\t\n\n\n\n1.Arithmetic"); > printf("\t\t\t\t\n2.Trigonometric"); > printf("\t\t\t\t\n3.Logarithm"); > printf("\t\t\t\t\n0.Quit"); > printf("\t\t\t\t\nEnter Ya Choice Dude: "); > scanf("%d", &x); > if(x==0) > break; file://what happens when 0 is entered > printf("Bye !"); > if(x==1) > {return submenu_arith()} file://what happens when 1 is entered > }
add: return 0; missing: } You tried to define a function within a function. This is not possible in C Quote: > void submenu_arith() missing { > int x; > while(1) > { > printf("\t\t\t\t\n\n\nArithmethic Menu); > printf("\t\t\t\t\n\n\n1.+?"); > printf("\t\t\t\t\n\n\n2.-?"); > printf("\t\t\t\t\n\n\n3./?"); > printf("\t\t\t\t\n\n\n4.*?"); > printf("\t\t\t\t\n\n\n5.Back to Main Menu"); > printf("\t\t\t\t\n\n\n6.Quit!"); > scanf("%d", &x); > if(x==0)break; > } > }
Bart v Ingen Schenau PS. Questions about C should not be posted to comp.lang.c++ -- FAQ for acllc-c++: http://www.raos.demon.co.uk/acllc-c++ Please reply to the group, so others can benefit also
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Thorsten Nit #4 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
Quote:
> Email me pls!
Write here, read here. This gives you reviewed answers for your benefit. Quote: Both C and C++ require int main(). Which of the two languages do you want to use? I assume C. [...] Your code doesn't compile. The curly braces don't match. So it is impossible to find out how your program is supposed to work. Give us the compilable code so that we can help you. F'up alt.comp.lang.learn.c-c++. -- HTH Thorsten
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Joona I Palast #5 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
on comp.lang.c: : Hey guys.. : need help badly because I still can't figure out : how to start! I guess I gonna fail my C programming.. : I just started.. and the calculator needs to use : either switch functions or if,else functions... : here is the code I type..- : maybe you guys can guide me through? : Email me pls! : #include<stdio.h> : #include<stdlib.h> : #include<conio.h> Non-standard header. : #include<math.h> : void mainmenu(void); : void submenu_arith(void); : file://void submenu_trigo(void); : file://void submenu_log(void); : file://float arifuncs() I suppose your newsreader is at fault, you didn't mean to type the file: parts. : void main() NO! void main() is incorrect! You should use int main()! : { : int x; : while(1) : { : printf("\t\t\t\t\n\n\nWeLComE"); : printf("\t\t\t\t\n\n\n\n1.Arithmetic"); : printf("\t\t\t\t\n2.Trigonometric"); : printf("\t\t\t\t\n3.Logarithm"); : printf("\t\t\t\t\n0.Quit"); Put linefeeds (\n) at the end of the lines. The way you are doing it is confusing, all those tabs don't do anything. : printf("\t\t\t\t\nEnter Ya Choice Dude: "); : scanf("%d", &x); : if(x==0) : break; file://what happens when 0 is entered : printf("Bye !"); Erm... This way your program will print "Bye !" if you don't enter "0". If you enter "0" it will just exit, and never get to this part. The way it should be is: if (x==0) { printf("Bye !\n"); break; Quote: }
: if(x==1) : {return submenu_arith()} file://what happens when 1 is entered Compiler error, return is missing a semicolon. Also, this way the program will end when submenu_arith() is finished. You should get rid of the return and just have submenu_arith(); here. : } : void submenu_arith() Another thing, if submenu_arith() is void, then returning its value in another function isn't going to return anything sensible. : int x; : while(1) : { : printf("\t\t\t\t\n\n\nArithmethic Menu); : printf("\t\t\t\t\n\n\n1.+?"); : printf("\t\t\t\t\n\n\n2.-?"); : printf("\t\t\t\t\n\n\n3./?"); : printf("\t\t\t\t\n\n\n4.*?"); : printf("\t\t\t\t\n\n\n5.Back to Main Menu"); : printf("\t\t\t\t\n\n\n6.Quit!"); Same problem here with the newlines. : scanf("%d", &x); : if(x==0)break; : } : } Other than these things I've pointed out, your code so far is fine. But I don't have the time to guide you in the actual calculation functions. --
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #80 D+ ADA N+++ | | http://www.*-*-*.com/ ~palaste W++ B OP+ | \----------------------------------------- Finland rules! ------------/ "When a man talks dirty to a woman, that's {*filter*} harassment. When a woman talks dirty to a man, that's 14.99 per minute + local telephone charges!" - Ruben Stiller
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Z #6 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
I just learned C. I need to do a project which uses simple C language. The project is to do a calculator which can perform 3 functions - trigo[sin,cos,tan], arithmethic[+,-,*,/], log I just started and I need to hand it up next Monday! Seriously speaking.. I don't know how to programm at the start! I have been learning for around 9 weeks or so only.. with only 1 lesson per week at 2 hrs per lesson.. ! I need help badly!
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Z #7 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
I have the sample program which the lecturer sent us.. you guys want it?
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Karl Heinz Buchegge #8 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
Quote:
> I have the sample program which the lecturer sent us.. you guys want it?
I don't think so. Why don't you take your time and ***study*** the sample program in depth. ----------------------------------------------------------- Karl Heinz Buchegger
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Z #9 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
i can't see the source code!!!
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
digital lot #10 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
ok, dude. check out the program you have, even though its just an executable. try plugging in different commands, work with it, *try to make it not work* - and then make your code output the same thing. it isn't as hard as you think. you posted some code, and we offered a good number of suggestions. go look at them. read mine. read joona's. read them all. and then dig in - it's your assignment, after all. ~digital lotus~ Quote:
>i can't see the source code!!!
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Karl Heinz Buchegge #11 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
Quote:
> i can't see the source code!!!
pardon me. so your lecturer gave you an executable, right. in this NG, program can mean 2 things: * source to a program * executable, generated from the source. usually, source code is ment, when anybody talks about a "program". ----------------------------------------------------------- Karl Heinz Buchegger
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Karl Heinz Buchegge #12 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
Quote:
> ok, dude. > check out the program you have, even though its just an executable. > try plugging in different commands, work with it, *try to make it not > work* - and then make your code output the same thing. > it isn't as hard as you think. you posted some code, and we offered a > good number of suggestions. go look at them. read mine. read joona's. > read them all. and then dig in - it's your assignment, after all.
to the OP: let me add one thing. Don't go for all the details at once. Take a systematic approach. Your first goal is to reproduce the main menu and asking the user of his/her choice. You next subgoal are the submenus. If the user enters the correct code, the right submenu should be shown. Make sure the user is able to reach the main menu again. After having all the submenues, the user has to choose the operation. Enter the users choice, and depending on that choice, ask for the parameters to the operation. Perform the operation, output the result and continue with the submenu. But the most important part is: Don't do all at once. Decide for goals you need to reach in the next step. Think how you could reach this goal, implement it and test it. Then go on for the next goal. ----------------------------------------------------------- Karl Heinz Buchegger
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
vrml3d.co #13 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
It sounds like what they are asking you to do is a "four function calculator with functions". For having only 3 months of C, this is a very challenging problem. I have a feeling that if you get anywhere near an answer, you'll surf the curve on this one. Did the prof even mention "parser generators", "lexical analyzers", or anything similar? Doing this with a parser generator (flex/bison or lex/yacc) is trivial, but doing it without one can be very tricky. I have in fact done one without it, because the ugly code generated by the generators bothered me, and I wanted to know how it worked. IMHO, they are really stretching you with this exercise. I wouldn't be surprised if the prof was just curious to see if any novel answers would arise from the students. He probably can't understand the code spat out by yacc either. --Steve
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Charles Woo #14 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
I doubt that ------- Really - Charles Wood
Quote:
>It sounds like what they are asking you to do is a "four function calculator >with functions". For having only 3 months of C, this is a very challenging >problem. >I have a feeling that if you get anywhere near an answer, you'll surf the >curve on this one. >Did the prof even mention "parser generators", "lexical analyzers", or >anything similar? >Doing this with a parser generator (flex/bison or lex/yacc) is trivial, but >doing it without one can be very tricky. I have in fact done one without >it, because the ugly code generated by the generators bothered me, and I >wanted to know how it worked. IMHO, they are really stretching you with >this exercise. I wouldn't be surprised if the prof was just curious to see >if any novel answers would arise from the students. He probably can't >understand the code spat out by yacc either. >--Steve
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Tim Stallman #15 / 16
|
 Help on a simple calculator program which needs Trigo, Arithmethic, log functions..[Apologies for repeat mail]
I bet his professor just meant to have the user choose a function (for example +), and then have the program prompt for two numbers to add and return the answer, not handle expressions. Quote:
> It sounds like what they are asking you to do is a "four function calculator > with functions". For having only 3 months of C, this is a very challenging > problem. > I have a feeling that if you get anywhere near an answer, you'll surf the > curve on this one. > Did the prof even mention "parser generators", "lexical analyzers", or > anything similar? > Doing this with a parser generator (flex/bison or lex/yacc) is trivial, but > doing it without one can be very tricky. I have in fact done one without > it, because the ugly code generated by the generators bothered me, and I > wanted to know how it worked. IMHO, they are really stretching you with > this exercise. I wouldn't be surprised if the prof was just curious to see > if any novel answers would arise from the students. He probably can't > understand the code spat out by yacc either. > --Steve
-- Tim Stallmann
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
|
Page 1 of 2
|
[ 16 post ] |
|
Go to page:
[1]
[2] |
|