Thread: New to C

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    13

    New to C

    I have a lab I have to do for class. The assignment is to make a loan calculator.

    This is what I have

    Code:
        /* Store the program in a file called intresest.c */
    #include <stdio.h>
    void main()
    {
        /* Declare and initialize variables */
        double principal = 10000.0;
        int term = 8.0;
        double rate = 8.0;
        double simple_interest = 0.0;
            scanf(%d, &principal);
            scanf(%d, &term);
            scanf(%d, &rate);
            scanf(%d, &simple_interest);
    
        /* Compute the simpole inerest */
        simple_interest = (principal * term * rate) / 100.0;
        printf("Total Interest = %6.21f/n", simple_interest);
    }
    When I try to build it I get an error "No input files"

    Is there any help I can have for this?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,339
    I think it would help if you posted your BUILD information. What platform / compiler?

    Todd

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    13
    Sorry, I am using a free ware called

    C-Free 3.5

    Any suggestions on free programs would be greatly appreciated.

  4. #4
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,339
    Is this an IDE or a console command driven compiler?

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    13
    I am not sure of the difference. I am new to programing and am taking it for a class in college. I do have some interest in learning but do not know very much.

  6. #6
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,339
    If C-Free a GUI application or are you entering some COMPILE command via the console?

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    13
    It is a GUI application. I believe similar to visual studio.

  8. #8
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,339
    Can you post the full output of the error information?

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    13
    This is the error as shown:

    [Error] g++.exe: No input files

  10. #10
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,339
    Doesn't look like you're supplying the input file as a parm.

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    8,866
    Your doubles should be input using the &#37;f, parameter.
    Code:
    Not:
    scanf(%d, &simple_interest);
    
    scanf(%f, &simple_interest);
    But I don't believe that's the cause of your error, right now. Sounds like stdio.h is not where it's expecting it to be.
    Last edited by Adak; 01-03-2008 at 06:21 PM.

  12. #12
    Registered User
    Join Date
    Jan 2008
    Posts
    13
    Quote Originally Posted by Todd Burch View Post
    Doesn't look like you're supplying the input file as a parm.
    How do I do this?

  13. #13
    Registered User
    Join Date
    Dec 2007
    Posts
    25
    Quote Originally Posted by Adak View Post
    Your doubles should be input using the %f, parameter.
    Code:
    Not:
    scanf(%d, &simple_interest);
    
    scanf(%f, &simple_interest);
    But I don't believe that's the cause of your error, right now. Sounds like stdio.h is not where it's expecting it to be.
    i believe that
    Code:
    scanf("%lf", &simple_interest);
    is better
    Code:
    # define EVERYTHINK 0
    int main ( void )
    { 
       while ( C_learning )
                 english_learning ( );
       return EVERYTHINK;
    }

  14. #14
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,339
    Quote Originally Posted by Shindel View Post
    How do I do this?
    Beats me. Read the help.

    Todd

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Shindel View Post
    This is the error as shown:

    [Error] g++.exe: No input files
    This is definitely that you are not supplying anything to g++ as input - the cause of this is probably that you haven't configured your project correctly - but that is a guess - as suggested, you will have to read the help for your particular IDE.

    Alternatively, you could use the command prompt (start menu->run... and type in "cmd"). Then use "cd" to move to the place where your file is, and type in "gcc interest.c"

    [I just noticed that this is C rather than C++, so for some reason your IDE is also assuming that you are building a C++ project rather than a C project - again, you have to choose the right configuration in your project settings].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed