Jump to content

Get a value from function.Problem

- - - - -

  • Please log in to reply
15 replies to this topic

#1
NicholasIT

NicholasIT

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
void tanFunc(double inputX)

{


	double value=inputX;

	double result;

	double sinx,cosx;

	sinx=sinxFunc(value);

	cosx=cosFunc(value);

	result=sinx/cosx;


	inputX=result;

	cout<<result<<endl;

	

	

}

im trying to get my sin function value and cos function value ,in case to calculate my tanx,however,it come out wf error cannot convert . error C2296: '%' : illegal, left operand has type 'double'
can anyone give some clues how to modify it ?

#2
zoranh

zoranh

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Do you have a function named sinx? Try renaming variable sinx into something else (less meaningful, e.g. double somethingElse). This error may indicate that in sinx/cosx expression compiler has concluded that sinx is a function or something like that, rather than double.

#3
NicholasIT

NicholasIT

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
ya,i got a function name sinxFunc(inputX)
i put it as result,however ,it give me the same result :S

#4
simislovas

simislovas

    Newbie

  • Members
  • Pip
  • 9 posts
show me your sinxFunc() code, then maybe i'll help.

#5
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1

Quote

error C2296: '%' : illegal, left operand has type 'double'
You can not use modulus operator with double or float as far as I know. Perhaps you could try this: fmod in math.h
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#6
NicholasIT

NicholasIT

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
hmmm,but i dint use modulus in my program @@''
however,i plan to do and i did it,somehow,it come out wf tht error oso @@''

#7
simislovas

simislovas

    Newbie

  • Members
  • Pip
  • 9 posts
NicholasIT
post sinxFunc code, its harrd to say what is wrong.
now i'm curious.

#8
NicholasIT

NicholasIT

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
hmm,here is my
void sinxFunc(double inputX)
{
//calculation,my result is return to inputX,while my inputX is the value that i put..
}


#9
zoranh

zoranh

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
What is the exact line on which compile error occurs?

#10
NicholasIT

NicholasIT

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
void tanFunc(double inputX)
{

	double value=inputX;
	double result;
	double sinx,cosx;
	sinx=sinxFunc(value); // here is my compile error
	cosx=cosFunc(value); // here also
	result=sinx/cosx;

	inputX=result;
	cout<<result<<endl;
	
	
}

hmm,my error is (208): error C2440: '=' : cannot convert from 'void' to 'double'

#11
simislovas

simislovas

    Newbie

  • Members
  • Pip
  • 9 posts
hmm, but with void function you are not getting the value, unless you are sending address and changing its data. but it's not as i can sea form declaration.
Maybe you'll want to do liak this:

double sinxFunc(double inputX)

{

	double result;

	//calculation

	return result;

}



#12
NicholasIT

NicholasIT

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
hmm?in case,i need to change my form to double ?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users