flowchart C++

Hey guys
Can you guys help me in my assignment.
My professor gave us assignment in flowchart about looping and we have to write the output of this flowchart.
and i wanna answer this by translating it to c++ compiler
this is the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
using namespace std;
int main()
{
    int x=5;
    int y=0;
    int z=1;
   for(;x>0;)
   {y=x;
       if(false)
       {
           cout<<"aw";
       }
       else if(true)
       {
           for(;y<=5;)
           {
               if(true)
              {
                  cout<<z;
                  z=z+1;
                  y=y+1;
              }
               else if(false)
               {
                   cout<<endl;
                   x=x-1;
                   z=1;
               }
}           }}}

i dont know if this is correct

no one replied :( i just you guys to help me in my assignment :((
Without knowing what the purpose of the program is: No, it's certainly not correct.

if(true) or if(false) doesn't make sense. Either it always executes or never. You need a condition that could be true or false.
if(true) or if(false) doesn't make sense

what do you mean by it.
if(false)
means if the for loop is false it would print out
aw


Last edited on
if ( false ) means the condition checked is always.. false That is to say, the condition can never evaluate to true so the code governed by the if condition will never be executed.

Loops are neither false nor true. They're loops.
ah i see.
can you fix my code? please :(
Read more about if and other control statement here:

http://www.cplusplus.com/doc/tutorial/control/
its not about it.

but im not only sure my translation in flow chart to real codes
I don't think anyone here knows what you're trying to change in your code besides what's already been said. What do you mean by "translating it"? Were you already given some form of code and you need to draw a chart of it? Or were you given a chart and you're making code from it?
Last edited on
my professor gave me a chart and im going to make code from it

can i upload picture in this forumn?
You'd have to upload to some other site and link. But in your if statements, what are you actually trying to test to be true or not? That's probably the biggest problem in the code you have.
Last edited on
okay wait im going to link it
@Ganado
wait wait forget the link there is something i forgot shit wait wait
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;
int main()
{
    int x=5;
    int y=0;
    int z=1;
   for(;x>0;)
   {y=x;
           for(;y<=5;)
           {
                  cout<<z;
                  z=z+1;
                  y=y+1;
               }
             cout<<endl;
              x=x-1;
              z=1;
     }
           cout<<"aw";
}
Last edited on
Damn >< is it really that simple? :(
Thank you all guys :)
now i can finally sleep.
the simulation is up to me.
thank you again
Topic archived. No new replies allowed.