why i got type mismatch in re redeclaration of function ComputeMeters ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gg236
    New Member
    • Oct 2013
    • 1

    why i got type mismatch in re redeclaration of function ComputeMeters ?

    Code:
    #include<stdio.h>
    int computeFeet(int yard);
    int computeInches(int yard);
    float computeMeters(int yard);
    main()
    {
    int yard ,f,i;
    float m ;
    clrscr();
    printf("Input value of yard :"); scanf("%d",&yard);
    
    f=computeFeet(yard);
    i=computeInches(yard);
    m=computeMeters(yard);
    
    printf("\n\nEquivalent values in :\nFeet :%d\nInches: %d\nMeters: %.2f",f,i,m);
    
    getch();
    }
    
     computeFeet(int yard)
    {
    int feet;
    
    feet=yard*3;
    return feet;
    }
    
     computeInches(int yard)
    {
    int inches;
    
    inches=yard*36;
    return inches;
    }
    
     computeMeters(int yard)
    {
    
    float meters;
    
    meters=yard*0.9144;
    
    return meters;
    }
    Last edited by Rabbit; Oct 28 '13, 05:19 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • stdq
    New Member
    • Apr 2013
    • 94

    #2
    Hi! Your function prototypes specify the return types, but this information must also be present in the function definitions. For example, line 37 should be

    Code:
    float computeMeters(int yard)

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Your function prototype shows ComputeMeters to return a float but where the function is defined there is no return type. That would mean default-int which is not supported by C++.

      Just add float as the return in the function definition and you are good to go.

      Comment

      Working...