# Converting loops error c2447 / Question/problem

Page 1 of 1

## 5 Replies - 3368 Views - Last Post: 23 February 2012 - 09:30 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=267838&amp;s=b5eac95bc2c6af070260fde817a8e749&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Mike92

Reputation: 0
• Posts: 3
• Joined: 22-February 12

# Converting loops error c2447 / Question/problem

Posted 22 February 2012 - 09:11 PM

```#include <iostream>

using namespace std;

int main ()

/*
convert the following while loop to a for loop:
int count = 0;
while ( count < 50) {
cout << " count is " << count << endl;
count++;
*/
{

int count = 0;                                   //start at 0
for (count = 0 ; count < 50; count++)            //Goes up to 50, adds by 1

cout << "The count is " << count << endl;

}
/*
convert the following for loop to a while loop:
//for ( int x = 50; x > 0; x--) {
//cout << x << " seconds to go.\ n";
*/

{
int x = 50;

while ( x > 0)
{
cout << "seconds to go" << x <<endl;
x--;
}

return 0 ;
}
```

MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

This post has been edited by JackOfAllTrades: 23 February 2012 - 04:28 AM

Is This A Good Question/Topic? 0

## Replies To: Converting loops error c2447 / Question/problem

### #2 Mike92

Reputation: 0
• Posts: 3
• Joined: 22-February 12

## Re: Converting loops error c2447 / Question/problem

Posted 22 February 2012 - 09:23 PM

I suppose I am asking what is wrong with this that it will not run? I am very new to doing this.

• Saucy!

Reputation: 6237
• Posts: 24,002
• Joined: 23-August 08

## Re: Converting loops error c2447 / Question/problem

Posted 23 February 2012 - 04:29 AM

Copy and paste your errors exactly as they appear in Visual Studio.

### #4 jimblumberg

Reputation: 4912
• Posts: 15,344
• Joined: 25-December 09

## Re: Converting loops error c2447 / Question/problem

Posted 23 February 2012 - 07:36 AM

You seem to have mismatched braces. Count your opening braces { and your closing braces } the number should match.

Jim

### #5 Mike92

Reputation: 0
• Posts: 3
• Joined: 22-February 12

## Re: Converting loops error c2447 / Question/problem

Posted 23 February 2012 - 06:06 PM

I cant seem to find a mismatched {, but I was also wondering if I should put this into the program so it runs both equations or will it do it automaticly?

#define pause system("pause")

then after the first block of code put this line in

pause;
Will this help the program compile?

### #6 jimblumberg

Reputation: 4912
• Posts: 15,344
• Joined: 25-December 09

## Re: Converting loops error c2447 / Question/problem

Posted 23 February 2012 - 09:30 PM

Quote

I cant seem to find a mismatched {

I think you need to review this link: Structure of a Program.

You have several missing or misplaced braces. Let's look at your code, stripped of all your commented code, and with the braces aligned for easier reading:
```#include <iostream>

using namespace std;

int main ()
{

int count = 0;                                   //start at 0
for (count = 0 ; count < 50; count++)            //Goes up to 50, adds by 1

cout << "The count is " << count << endl;

}

{
int x = 50;

while ( x > 0)
{
cout << "seconds to go" << x <<endl;
x--;
}

return 0 ;
}

```

As you should be able to see you have a section of code that does not belong to any function.

Jim