954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

coding if loops

How do I code an IF loop to perform the following?:

if a > X
b = //a value//
else
b = //another value//

Thanks!!

matt_5104
Newbie Poster
15 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 
int a = 5;
int b = 7;

if (a > b)
{
   b += 1;
}
else 
{
  b -= 1;
}

Is this what your talking about?

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

is IF a loop ??? heard it for the first time ?? :D

nanosani
Unauthenticated Liar
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

Looks like conditional statment to me ;) ??

pajac
Light Poster
33 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

It can be used as a recursive function. I guess that's what he was talking about...Maybe...?

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

Hm........now u got us!!! ;)

pajac
Light Poster
33 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 
10 a=1
20 if (a=1) goto 10


Loopy enough? Not Java of course ;)

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 
10 a=1
20 if (a=1) goto 10

Loopy enough? Not Java of course ;)

We had Prolog last semester..... Rekursion is not my favorite, but it'll go. :cool:

pajac
Light Poster
33 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You