Help for the error in dev c++

Discussion in 'Programmer's Corner' started by mkbutan, Aug 2, 2012.

  1. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    hi
    can any one guide what iam doing wrong in this program as dev c++ compiler giving error which i cant understand here is the print screen of the same and the code

    Code ( (Unknown Language)):
    1. /*
    2.   Name: mkbutan
    3.   Copyright:
    4.   Author:
    5.   Date: 02/08/12 20:38
    6.   Description: pg8  1.5
    7. */
    8. #include<stdio.h>
    9. #include<conio.h>
    10. #define PERIOD   10
    11. #define PRINCIPAL  5000.00
    12. main()
    13. {
    14. int year;
    15. float amtount,value,inrate;
    16. [COLOR="Red"]amount = PRINCIPAL;[/COLOR]
    17. inrate = 0.11;
    18. year = 0;
    19. while(year<=PERIOD)
    20. {
    21.                    printf("%2d %8.2f\n",year,amount);
    22.                    value = amount + inrate * amount;
    23.                    year = year + 1;
    24.                    amount = value;
    25.                    }
    26. getch();
    27. }
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    You didn't define amount, you defined amtount. :D

    Code ( (Unknown Language)):
    1.  
    2. float [U][B]amtount[/B][/U],value,inrate;
    3. amount = PRINCIPAL;
     
    mkbutan likes this.
  3. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    thanks dear it was my silllllllly mistake , but it took my full day to understand and just rectified by you by just one post
    thanks once again
     
  4. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    hi sir is this code correct? pl help.
    Code ( (Unknown Language)):
    1. /*
    2.   Name: mkbutan
    3.   Copyright:
    4.   Author:
    5.   Date: 02/08/12 23:06
    6.   Description: exec 1.5 pg21
    7. */
    8. #include<stdio.h>
    9. #include<conio.h>
    10. void main()
    11. {
    12.      int r,x;
    13.      float pi;
    14.      printf("Enter the Radius : \n",r);
    15.      scanf("%d",r);
    16.      x = (2*pi*r)*(2*pi*r);
    17.      printf("The Area of a Circle is : %d",x);
    18.      getch();
    19.      }
    20.  
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    The area of a circle is ∏ times radius squared, or in C:

    x = pi*r*r; // since C doesn't have a square function

    And don't forget to define pi either.

    It looks like you want to calculation to be repeated over and over... hence your getch() To get that to work you need to put the code inside a loop.
     
    Brownout and mkbutan like this.
  6. Brownout

    Well-Known Member

    Jan 10, 2012
    2,375
    998
    Hi ErineM,

    When C programs run in a console, the console terminates as soon as the program finished. If one wants to see the results, he need to prevent that from happening. That might be the reason for the getche().
     
Loading...