PDA

View Full Version : If function


xgirl
03-23-2002, 09:27 AM
Hi,

Could anyone explain to me the following code?

if(acquire(),NULL)
{
return true;
}

where acquire() is just a user-defined function.

Why is it the 'if' function can contain two parameters?

Thank you.

aym
03-24-2002, 11:46 AM
First you have to tell us which programming language you are using.

xgirl
03-24-2002, 08:49 PM
Hi,

I'm using C programming.

j0hn d0e
03-24-2002, 09:33 PM
Hola xgirl

The way I understand the IF statement is:

IF(expression) statement

Where expression is, you would have the the expression being evaluated. Where statement is you would have the instruction to execute. If the expression returns True, then the statement is executed. i.e

x=100

If(x==100)
cout << "x is 100";

If you have multiple lines of code to execute then:

if(x==100)
{
cout <<"The value of x is ";
cout<< x ;
}

You can have multiple expressions evaluated:

if(x==100 || x==0)
{
cout<<"The value of x is";
cout<< x ;
}

If x is 100 or 0 the code will be executed.

Hope that helps

jd

aym
03-25-2002, 07:24 AM
Originally posted by xgirl
Hi,

I'm using C programming.
As I know (and I have some experience in C), if satement has only one usage, and j0hn d0e explained it well.