# code conversion

Page 1 of 1

## 3 Replies - 619 Views - Last Post: 17 October 2012 - 03:40 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=295019&amp;s=ea1b1911796aea048a99e78d92c3aa28&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 fsdfsdfsd1

• New D.I.C Head

Reputation: 0
• Posts: 21
• Joined: 04-October 12

# code conversion

Posted 10 October 2012 - 12:29 AM

//vb code
for d=1 to 15+1
//c++ code
for(int d=1;d<15;d++)
//is it right?

Is This A Good Question/Topic? 0

## Replies To: code conversion

### #2 DimitriV

• vexing conundrum

Reputation: 587
• Posts: 2,746
• Joined: 24-July 11

## Re: code conversion

Posted 10 October 2012 - 12:31 AM

Yes, it is.

Just remember, you need to open braces to define the loop body:
for (int d=1; d < 15; d++) {
// code goes within braces
}

### #3 janne_panne

• WinRT Dev

Reputation: 428
• Posts: 1,047
• Joined: 09-June 09

## Re: code conversion

Posted 10 October 2012 - 12:39 AM

I don't think that's right. The condition seems to be different:
In C++ code, d will get a maximum value of 14, before turning to 15 and stepping out of the loop.
In VB code, to my understanding, d would be 16 before it "turns into 17" and steps out of the loop.
So VB code runs 16 iterations compared to C++'s 14 iterations.
To fix it, VB code should be "15-1" instead of "15+1" or C++ code should be "d <= 15+1"

### #4 BobRodes

• Lovable Curmudgeon

Reputation: 590
• Posts: 3,041
• Joined: 19-May 09

## Re: code conversion

Posted 17 October 2012 - 03:40 PM

I agree with janne.