Thread: Math equation help!!

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    7

    Math equation help!!

    Code:
    #include <stdio.h>
    #include <math.h>
    
    int main ()
    {
    
    float pr;
    float ir;
    int yrs;
    int comp;
    double future_value;
    
    printf("Enter your amount invested (principle).\n");
    scanf("%f", &pr);
    printf("Enter your interest rate.\n");
    scanf("%f", &ir);
    printf("Enter your number of years.\n");
    scanf("%d", &yrs);
    printf("Enter your number of compounding periods.\n");
    scanf("%d", &comp);
    
    printf("Future value of investment: %f", future_value);
    
    future_value = pr * pow (1+ir/comp,yrs*comp);
    i don't see what i'm doing wrong but I always get 0.00000 for an answer. please if you could point me in the right direction thanks!

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    You're printing future_value before you calculate it.
    Code:
    while(!asleep) {
       sheep++;
    }

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    7
    ouch lol thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do a math equation in c Programming
    By jabber5050 in forum C Programming
    Replies: 6
    Last Post: 09-08-2011, 01:08 PM
  2. Need help reducing an equation, math wiz's welcome. =)
    By M.Richard Tober in forum C++ Programming
    Replies: 6
    Last Post: 07-23-2011, 05:45 PM
  3. C++ math equation
    By XodoX in forum C++ Programming
    Replies: 22
    Last Post: 03-02-2009, 12:02 AM
  4. Converting String to Math Equation
    By draggy in forum C++ Programming
    Replies: 5
    Last Post: 07-10-2005, 06:59 PM
  5. A math equation
    By dizolve in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-17-2002, 12:56 PM