flowchart C++

Jul 2, 2014 at 10:52am
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

Jul 2, 2014 at 11:07am
no one replied :( i just you guys to help me in my assignment :((
Jul 2, 2014 at 11:13am
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.
Jul 2, 2014 at 11:24am
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 Jul 2, 2014 at 11:25am
Jul 2, 2014 at 11:27am
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.
Jul 2, 2014 at 11:34am
ah i see.
can you fix my code? please :(
Jul 2, 2014 at 11:59am
Read more about if and other control statement here:

http://www.cplusplus.com/doc/tutorial/control/
Jul 2, 2014 at 12:28pm
its not about it.

but im not only sure my translation in flow chart to real codes
Jul 2, 2014 at 12:30pm
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 Jul 2, 2014 at 12:32pm
Jul 2, 2014 at 12:33pm
my professor gave me a chart and im going to make code from it

can i upload picture in this forumn?
Jul 2, 2014 at 12:44pm
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 Jul 2, 2014 at 12:44pm
Jul 2, 2014 at 1:02pm
okay wait im going to link it
Jul 2, 2014 at 1:24pm
Jul 2, 2014 at 1:29pm
@Ganado
Jul 2, 2014 at 1:31pm
wait wait forget the link there is something i forgot shit wait wait
Jul 2, 2014 at 1:35pm
Last edited on Jul 2, 2014 at 1:35pm
Jul 2, 2014 at 1:41pm
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 Jul 2, 2014 at 1:42pm
Jul 2, 2014 at 1:49pm
Damn >< is it really that simple? :(
Jul 2, 2014 at 1:54pm
Thank you all guys :)
now i can finally sleep.
the simulation is up to me.
thank you again
Topic archived. No new replies allowed.