   Weird Output on my Calculator Program
  Hello Peeps! Can you guys help me with this. I'm using visual C++ with this calculator program the problem is when I run the program it does not do calculation at all!  What could be the problem in my code? I just started programming in VC++ a week ago so if anyone willing to help me with these,  I will really appreciate it.#include <stdio.h>#include <conio.h>#include <iostream.h>void addition();void subtraction();void multiplication();void division();float a,b;main(void){char ch;printf("choose an operation");printf("\n(A)ddition");    printf("\n(S)ubtraction");printf("\n(M)ultiplication");printf("\n(D)ivision");printf("\npress X key to exit\n");  printf("choose operation to perform: ");ch=getche();switch(ch){  case 'a':  addition();  break;  case 's':  subtraction();  break;  case 'm':  multiplication();  break;  case 'd':  division();  break;  case 'X':  getch();}    return(getche());}void addition(){printf("\nEnter first number: ");scanf("%d",&a);printf("\nEnter second number: ");scanf("%d",&b);    a=a+b;printf("%d",a);getche();main();}void subtraction(void){    printf("\nEnter first number: ");scanf("%d",&a);printf("\nEnter second number: ");scanf("%d",&b);    a=a-b;printf("%d",a);getche();main();}void multiplication(void){ printf("\nEnter first number: ");scanf("%d",&a);printf("\nEnter second number: ");scanf("%d",&b);    a=a*b;printf("%d",a);getche();    main();}void division(void){    printf("\nEnter first number: ");scanf("%d",&a);printf("\nEnter second number: ");scanf("%d",&b);    a=a/b;printf("%d",a);getche(); main();}Here is what happens. When I run the program it displays: Choose an operation:as soon as I choose an operation let's say I entered A for Addition it then displays:  Enter the First Numbers: A<--My problem is here!and then after I entered the second number, it does'nt do calculations!    No Signature[edited by - makoy on February 11, 2004 7:52:59 AM]
  You are using %d. %d is used for int''s, not float''s. You should be using %f. ;  You''re also calling main() from within your functions (addition, subtraction, etc.)  You don''t have to do that.  Your program will automatically return to where it was once the function is done.Example:Main -> Function -> Main -> Function -> Main -> FunctionFollow that?It can also go multiple, multiple levels deep:Main -> Function (F1) --> Function In F1 -> Function (F1) -> MainIt forms a half-ass tree.Main-> Function (F1)--> Function In F1-> Function (F1)MainHope you follow. ;Example:Main -> Function -> Main -> Function -> Main -> FunctionFollow that?It can also go multiple, multiple levels deep:Main -> Function (F1) --> Function In F1 -> Function (F1) -> MainIt forms a half-ass tree.Main-> Function (F1)--> Function In F1-> Function (F1)MainHope you follow. So how should I write my code? Sorry if I'm being dumb dude but I did'nt get what you mean. I mean, how should I declare my Main()? Because as what I understand, Functions are not covered by the main() unless you put a return() in it. And besides I only declare main in my functions so that I can get back to the main after the function() is done with it's operation.   No Signature   [edited by - makoy on February 11, 2004 7:49:12 AM]