Conditional statements?

I am having a problem remembering how to do a conditional statement. It's the odd way of doing an if statement. I think that it goes something like this:


int a = -1;

a ? a < 0 : -a;


This very very simple example should just work as an absoulute function. Please, does anyone know what the correct syntax is for this?




Comments

  • I just remembered how to do it. =)

    The statement would look sort of like this:


    int a = -1;


    a = (a<0) ? -a&&printf("%i is negative number
    ",a): a&&printf("%i is Positive
    ",a);<p>
    printf("|a| = %i
    ",a);




    : I am having a problem remembering how to do a conditional statement. It's the odd way of doing an if statement. I think that it goes something like this:


    : int a = -1;

    : a ? a < 0 : -a;


    : This very very simple example should just work as an absoulute function. Please, does anyone know what the correct syntax is for this?







Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories