1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Where is the simple error?

Discussion in 'C' started by cquestion, Dec 5, 2007.

  1. cquestion

    cquestion New Member

    Joined:
    Oct 25, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Hello, i'm going mad because I can't find the problem in this simple code. Why do this don't work?
    Code:
    float promedi(a,b)
    {
    return ((a+b)/2);
    }
    
    main()
    {
    float x,y;
    printf("Dame dos valores\n");
    scanf("%f%f", &x, &y);
    printf("%f",promedi(x,y));
    system("pause");
    }
    I got at least two different errors (strange long number solutions, window must close...).
     
    Last edited by a moderator: Dec 6, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    float promedi(a,b) is not the right way of defining the function. it should be float promedi(float a, float b)
     
  3. cquestion

    cquestion New Member

    Joined:
    Oct 25, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Hello shabbir. Thanks a lot for your help :). I'm sorry, I created two posts by mistake.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    My pleasure
     

Share This Page