flowchart help

Can you do two 'if' statements in a row? For instance

if(x<10)
if(y>10)
cout<<"*****"<<endl;
else
cout<<"#####"<<endl;
cout<<"$$$$$"<<endl;

So if I could do a flow chart that would be like (I'm not very good at flow charts). I would like the code to check if x<10 and if it is, then do an if/else.

(x<10)
|
(y>10)------------------------------------------- cout<<"#####"<<endl; cout<<"$$$$$"<<endl;
|
cout<<"*****"<<endl;



Last edited on
1
2
3
4
5
6
7
if (x<10)
{
  if (y>10)
  {
      //do something because x is less than ten and y is greater than 10
  }
}


More commonly combined:

1
2
3
4
if ( (x<10) && (y>10) )
{
    //do something because x is less than ten and y is greater than 10
}


Flow charts are a very old means of thinking about programming and as soon as you start bringing proper classes into the picture become as much of a hindrance as a help. You can get away with using them for very simple programs without persistent states, but even then it's a good idea to get away from thinking in terms of flow charts.
Last edited on
Ok, so I would have to write it like this, I think. Is that correct?

if(x<10)
}
if(y>10)
{
cout<<"*****"<<endl;
else
cout<<"#####"<<endl;
cout<<"$$$$$"<<endl;
}
}
How do you get it numbered like how you did?
1
2
3
4
5
6
7
8
9
10
if(x<10)
}
    if(y>10)
    {
        cout<<"*****"<<endl;
    else
        cout<<"#####"<<endl;
        cout<<"$$$$$"<<endl;
    }
} 
Oh I got it, I think.
Topic archived. No new replies allowed.