Thread: Problem In Function Program

  1. #1
    Registered User
    Join Date
    Mar 2011

    Problem In Function Program

    Please help me guys,
    I have been given an assignment

    "Task:- Write a function that accept a person salary in long integer, rate of interest & return the yearly investment "

    I have made a following program!

    Please point out my mistake here please

    float inve(long,long);
    float inte(long,long);
    float sum(long,long);
    void main(void)
    long c;
    long a;
    long b;
    printf("Enter The Monthly Salary Of A Person:");
    printf("Enter The Rate Of Interest Of A Person:");
    printf("\nThe Rate In A Numbers:%ld",inve(a,b));
    printf("\nThe Difference Of Interest And A Salary %ld",inte(a,b));
    printf("\nThe Yearly Investment Is %ld",sum(c,b));
    float inve(long x,long y)
    int inte(long w,long v)
    int sum(long q,long r)

  2. #2
    Registered User
    Join Date
    Sep 2004
    First, you need to learn how to properly indent source code. This will make it easier for others to read.

    Next, instead of just asking for what mistakes you've made, tell us what output you expect to get and how that is different from the output you are getting.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Give your functions and variables (especially) meaningful names.

    a and b are useless.
    salary and interest would be better.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Sorry Friends, I am new to Programming that is why, I am amking mistakes in following rules of this forums and writing programs in a meaningful way!
    Thanks for your guidance!

  5. #5
    Registered User
    Join Date
    Sep 2008
    Toronto, Canada
    Your definitions: long c; long a; long b; should go first before any code. Before clrscr();
    In inve(), if you intend to get a float result you must ensure the calculation is done in float:
    Then your printf should have the proper formatting for float:
    "\nThe Rate In A Numbers:%f"
    The inte() function should return a long. Not int.
    You're not calculating a value for 'c' anywhere.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM