Invalid Operands to Binary +

why am I getting this error

Page 1 of 1

4 Replies - 49176 Views - Last Post: 22 February 2008 - 05:26 AM Rate Topic: -----

#1 jediokie  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 215
  • Joined: 07-February 08

Invalid Operands to Binary +

Post icon  Posted 13 February 2008 - 11:24 AM

#include <stdio.h>
#include <math.h>

float average(int,int,int);
int median(int, int,int);
float slumpf(int, int);
float RMS(float, float, float, float);

int main(void)
{
   float ans;
   [b]ans=(float)(average + median + slumpf + RMS);[/b]
   printf("%f\n",ans);
}



Subroutines were omitted for length
Every time I try to complie this code I get the invalid operands error message. First what does this error mean? Second how might I avoid it in the future?

Is This A Good Question/Topic? 0
  • +

Replies To: Invalid Operands to Binary +

#2 letthecolorsrumble  Icon User is offline

  • Student of The Sun
  • member icon

Reputation: 27
  • View blog
  • Posts: 555
  • Joined: 07-November 07

Re: Invalid Operands to Binary +

Posted 13 February 2008 - 11:32 AM

View Postjediokie, on 13 Feb, 2008 - 11:24 AM, said:

#include <stdio.h>
#include <math.h>

float average(int,int,int);
int median(int, int,int);
float slumpf(int, int);
float RMS(float, float, float, float);

int main(void)
{
   float ans;
   [b]ans=(float)(average + median + slumpf + RMS);[/b]
   printf("%f\n",ans);
}



Subroutines were omitted for length
Every time I try to complie this code I get the invalid operands error message. First what does this error mean? Second how might I avoid it in the future?

You are using functions as variables.
ans=(float)(average + median + slumpf + RMS);
change that to
ans=(float)(average(1,2,3) + median(1,2,3) + slumpf(1,3) + RMS(1,2,3,4)); //Just an example


That will just remove the syntax errors, to remove linking and run-time errors if they occur, please post the rest of the code.

:)

This post has been edited by letthecolorsrumble: 13 February 2008 - 11:34 AM

Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Invalid Operands to Binary +

Posted 13 February 2008 - 11:32 AM

(average + median + slumpf + RMS);


The specified variables do not exist. Should they be function calls?
Was This Post Helpful? 0
  • +
  • -

#4 jediokie  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 215
  • Joined: 07-February 08

Re: Invalid Operands to Binary +

Posted 13 February 2008 - 11:48 AM

View Postletthecolorsrumble, on 13 Feb, 2008 - 11:32 AM, said:

View Postjediokie, on 13 Feb, 2008 - 11:24 AM, said:

#include <stdio.h>
#include <math.h>

float average(int,int,int);
int median(int, int,int);
float slumpf(int, int);
float RMS(float, float, float, float);

int main(void)
{
   float ans;
   [b]ans=(float)(average + median + slumpf + RMS);[/b]
   printf("%f\n",ans);
}



Subroutines were omitted for length
Every time I try to complie this code I get the invalid operands error message. First what does this error mean? Second how might I avoid it in the future?

You are using functions as variables.
ans=(float)(average + median + slumpf + RMS);
change that to
ans=(float)(average(1,2,3) + median(1,2,3) + slumpf(1,3) + RMS(1,2,3,4)); //Just an example


That will just remove the syntax errors, to remove linking and run-time errors if they occur, please post the rest of the code.

:)

That did it thanks so much.
Was This Post Helpful? 0
  • +
  • -

#5 selloorhari  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 68
  • Joined: 07-February 08

Re: Invalid Operands to Binary +

Posted 22 February 2008 - 05:26 AM

In your program average, median,slumpf & RMS are functions, Which will be called by its value.. Right.. Then you are calling those function with nothing.. I think there lies the problem!!!
Change like...

ans = (float) ( average(3,4,5) + median (3,4,6) + slmpf(3,4) + RMS (3.4,4.5,5.6,6.7) ) ;

I think this my work!!!

This post has been edited by selloorhari: 22 February 2008 - 05:28 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1