Hi I was wondering if you could help me with the following errors.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abrown07
    New Member
    • Jan 2010
    • 27

    Hi I was wondering if you could help me with the following errors.

    Code:
    #include <stdio.h>
    
    int main(void)
    {
    
    	double percent,dollars,periods,Future
    
    	Future value of investment = dollars(1+percent)pow(periods)
    
    	printf("Interest rate per period: ");
    	scanf("%lf", &percent);
    
    	printf("Present value: ");
    	scanf("%lf", &dollars);
    
    	printf("Number of periods: ");
    	scanf("%lf", &periods);
    
    	printf("Future value of investment: $%.2f\n",Future);
    	return 0;
    }


    When attempting to compile i get:

    abrown05@potter :~/Documents$ gcc -Wall Investment.c
    Investment.c: In function ‘main’:
    Investment.c:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Future’
    Investment.c:19 : error: ‘Future’ undeclared (first use in this function)
    Investment.c:19 : error: (Each undeclared identifier is reported only once
    Investment.c:19 : error: for each function it appears in.)
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You have 2 errors at line 6 and 8. The errors reported at line 19 are just a knock-on effect of the other errors.

    As indicated by the first error message, expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ , means it is missing one of those things and that is exactly the problem no ; at the end of line 6, reported at line 8 because that is the first place it can detect the error.

    After you fix that you will start getting errors at line 8 because line 8 in no way conforms to C syntax. It looks more like it should be a comment explaining what the program does since it includes "value of investment" all of which are completely undefined by the program.

    I also suggest you look up the function pow() when re-writing that line.

    P.S. Please post code in [code]...[/code] tags, it preserves formatting among other things.

    Comment

    Working...