Sasanka Pabasara
Sasanka Pabasara

Reputation: 45

How to draw a control flow graph for a nested for loop?

for(num2 = 0; num2 <= 3;  num2++)
{
  for(num1 = 0; num1 <= 2; num1++)
  {
        cout<< num2<< "   " << num1<< endl;
  }
} 

how to draw a control flow graph for the above code segment?

Thanks in advance :)

Upvotes: 3

Views: 2499

Answers (1)

Luc
Luc

Reputation: 6026

I am studying for a test on this and it's still kind of vague, so I might be wrong, but I think it should be this:

  O<
 /| \
/ v /
| O<
| | \
| v /
| O
\
 >O

Please let me know if you got the same result, or if the graph is unclear I'll make a proper one.

Upvotes: 4

Related Questions