home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2404 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  82 lines

  1. Path: news.magic.mb.ca!techtol!tahir.khawaja
  2. From: tahir.khawaja@techtol.magic.mb.ca (Tahir Khawaja)
  3. Date: 30 Jan 96 08:52:00 
  4. Newsgroups: comp.sys.amiga.programmer
  5. Subject: silly c problem
  6. Message-ID: <f2c_9601302132@techtol.magic.mb.ca>
  7. Organization: Techtol FidoGate
  8.  
  9. #include <stdio.h>
  10.  
  11. main()
  12. {
  13.   int num1, num2, res, ope, err;
  14.  
  15.   printf("Please input two number!\n");
  16.   scanf("%d%d", &num1, &num2);
  17.   printf("You entered %d and %d.\n\n", &num1, &num2);
  18.   printf("And now the code for the operation!\n");
  19.   printf("1=Add, 2=Subtract, 3=Multiply, 4=Divide\n");
  20.   scanf("%d", &ope);
  21.   printf("You entered %d.\n\n", &ope);
  22.   err = 1;
  23.   if(ope == 1)
  24.     {
  25.       res = num1 + num2;
  26.       err = 0;
  27.     }
  28.   if(ope == 2)
  29.     {
  30.       res = num1 - num2;
  31.       err = 0;
  32.     }
  33.   if(ope == 3)
  34.     {
  35.       res = num1 * num2;
  36.       err = 0;
  37.     }
  38.   if(ope == 4)
  39.     {
  40.       res = num1 / num2;
  41.       err = 0;
  42.     }
  43.   if(err == 1)
  44.     printf("Wrong Code! Input only number 1 - 4!\n");
  45.   else
  46.     printf("The result is %d %d %d %d\n.", &num1, &num2, &res, &err);
  47. }
  48. -------------------------------
  49.  
  50.      pretty simple right?
  51.  
  52. --------------------------------
  53. Please input two number!
  54. 2 2
  55. You entered 2817020 and 2817016.
  56.  
  57. And now the code for the operation!
  58. 1=Add, 2=Subtract, 3=Multiply, 4=Divide
  59. 1
  60. You entered 2817008.
  61.  
  62. The result is 2817020 2817016 2817012 2817004
  63. ----------------------------------
  64.  
  65.      so what am i doing wrong.  i'm an absolute beginner at c but not at
  66. programming.  the books i have don't tell me any different way to do this.  im
  67. compiling w/ 'gcc -noixemul -o math math.c'  also pretty simple.  do i need to
  68. #include some more stuff?
  69.  
  70. bye
  71.  
  72.  
  73. ---
  74. Tahir.Khawaja@techtol.magic.mb.ca                         Paradox Programmer
  75. Data: 1-204-261-7820                                  Voice : 1-204-275-2344
  76. --
  77. |Fidonet:  Tahir Khawaja 1:348/705
  78. |Internet: tahir.khawaja@techtol.magic.mb.ca
  79. |
  80. | Standard disclaimer: The views of this user are strictly his own.
  81.  
  82.