program compiles... doesn't work

Discussion in 'C' started by inspiration, Mar 28, 2010.

  1. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    Hi all... this bit of code compiles fine with mingW, but gives me no output!

    Code:
    #include <stdio.h>
    #include <math.h>
    #include <float.h>
    #include <stdlib.h>
    
    long cap_reac();
    long c, freq, a;
    
    int main()
    {
    printf("input the cap value...\n");
    scanf("l%", &c);
    printf("input the frequency...\n");
    cap_reac();
    cap_reac()
    }
    { long c, freq, a;
    a =(159.2/(c * freq));
    printf("%l equals... " , a);
    }
    
     
  2. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    We've got quite a few problems here.

    You define some global variables then try to define them again within the function.
    The prototype says the function is a long and where you define the function you havent specified what type it is.
    You've closed a bracket where the function definition is, you should have closed it at the end of main().
    There is no scanf call to get the frequency from the user.

    Needs a bit of work.
     
  3. techme

    techme New Member

    Joined:
    Feb 15, 2010
    Messages:
    86
    Likes Received:
    0
    Trophy Points:
    0
    After compile time errors come the run time errors. The latter don't generate messages, just black screens or lockups. Then you get to use (or write) a debugger.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice