Click here to Skip to main content
15,887,992 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello all,

I have a code in excel, which I need to convert into c++. I cant understand the looping. If anybody can help, that would b great!

=IF((C6-A6)>0, IF((D6-B6)>0,ATAN((C6-A6)/(D6-B6))*180/PI(),180+ATAN((C6-A6)/(D6-B6))*180/PI()),IF((D6-B6)>0,360+ATAN((C6-A6)/(D6-B6))*180/PI(),180+ATAN((C6-A6)/(D6-B6))*180/PI()))


for ease of understanding I have split these into lines :
=IF((C6-A6)>0, 
IF((D6-B6)>0,
ATAN((C6-A6)/(D6-B6))*180/PI(),
180+ATAN((C6-A6)/(D6-B6))*180/PI()),
IF((D6-B6)>0,
360+ATAN((C6-A6)/(D6-B6))*180/PI(),
180+ATAN((C6-A6)/(D6-B6))*180/PI()))


I don't understand why is there two "If" statements...
Posted
Updated 26-Apr-12 1:16am
v2

1 solution

as i could figure out from those lines : the IF works like this

IF(Condition True, Do/Evaluate this, Else Do/Evaluate this).


and for the Double IF:

If (Condition 1 is true,
the expression to evaluate is the seond one beginning by another IF ....)

it is like

C++
if( Cond1 ....)
  if( Cond2 ....)
 
Share this answer
 
Comments
Sumal.V 26-Apr-12 7:32am    
But out of the 3 if statements, the 2nd and the third are same.... I don't get the point.
Schehaider_Aymen 26-Apr-12 7:53am    
The conditions of the sencond and the third "if" are the same but they differ with their instructions besides the body of the second if executed only if the first condition (C6-A6)>0 is verified.

So it will look like this

<pre lang="c++">
if((C6-A6)>0)
{
if((D6-B6)>0)
//[Bloc 1 ]ATAN((C6-A6)/(D6-B6))*180/PI()
else
//[Bloc 2 ]180+ATAN((C6-A6)/(D6-B6))*180/PI())
}
else
{
if((D6-B6)>0)
//[Bloc 3 ]360+ATAN((C6-A6)/(D6-B6))*180/PI()
else
//[Bloc 2 ]180+ATAN((C6-A6)/(D6-B6))*180/PI()
}
</pre>
Sumal.V 26-Apr-12 8:12am    
Oh okay, cheers

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900