Thread: Something is wrong???

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    18

    Something is wrong???

    I'm trying to prompt and print principal,rate,and days; and compute and display interest. The following doesn't seem to work. Any thoughts for correcting? The copile error I get on the last print is statement missing and after that I get a warning that "interest" is assigned a value that is never used. DW

    #include<stdio.h>

    void main(void)
    {

    int principal;
    int rate;
    int days;
    int interest;

    /* Prompt to enter principal*/

    printf("\nEnter principal ");

    scanf("%d",&principal);

    /*Prompt to enter rate*/

    printf("\nEnter rate ");

    scanf("%d",&rate);

    /* Prompt to enter days*/

    printf("\nEnter days ");

    scanf("%d",&days);

    /*Print out the interest charge*/

    interest=(principal*rate*days)/365

    printf("\nThe interest charge is %f", principal*rate*days/365);



    }

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    use [ code ] [ /code ] tags
    and its
    Code:
    int main(void){
    
      ...
      return 0;
    }
    Code:
    printf("\nThe interest charge is %f", principal*rate*days/365);
    should be
    Code:
    printf("\nThe interest charge is %d", interest);

  3. #3
    Not just a squid...
    Join Date
    Sep 2004
    Posts
    25
    While I agree with sand_man that you don't need to reuse the formula when you are storing the result in interest, I also noticed that you left a semicolon off of this line:
    Code:
    interest=(principal*rate*days)/365

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    66
    There is a symbol ( missing, it should go:
    interest=(principal*rate*days)/365 ; with the ; symbol

    instead of
    interest=(principal*rate*days)/365

    that is why it says "statement missing"

    and also the correction sand_man made is needed

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    1
    Shouldn't interest, rate, and principal also all be floats? Otherwise there will be serious rounding errors...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM