6 Replies - 59647 Views - Last Post: 28 March 2009 - 02:59 PM Rate Topic: -----

#1 mixch_s  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 8
  • Joined: 26-March 09

How to draw flowchart for SWITCH?

Posted 28 March 2009 - 12:57 PM

Is there possible to draw flow chart switch?

example;
i want to draw flow chart of these code
switch ( num )
			{
				case 0 : cout << endl;
				            break;
				case 3 : cout << "A";
				case 2 : cout << "A";
				case 1 : cout << "A" << "\n";
				            break;	
				case 4 : cout << "B" << "\n";
			                	 break;
				case 5 : cout << "C" << "\n";
					 break;
				case 6 : cout << "D" << "\n";
					 break;	
				case 7 : cout << "E" << "\n";
					 break;
				case 8 : cout << "F" << "\n";
					 break;
				case 9 : cout << "G";
				case 10 : cout << "H" << endl;				 		                                            break;	
			}

One way is draw diamond and ask whether num is 3, or 2 or 1 or 4......so on
so it will be very long as there will be 10 diamonds have to be drawn
Is there any alternative way???

Is This A Good Question/Topic? 2
  • +

Replies To: How to draw flowchart for SWITCH?

#2 Plus  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 41
  • View blog
  • Posts: 414
  • Joined: 24-November 08

Re: How to draw flowchart for SWITCH?

Posted 28 March 2009 - 01:11 PM

in Flowcharts there are the old way, which is
to use multiple <condition>'s ...

the new way is to use one <condition> that take out
more than a flow-line !

	   ( start )
		   |
	 	  v   2
		< i= ?> -------> ...
	 	  |
		   v 4
	 	 ...
		   |
		   v
		( end )


This post has been edited by Plus: 28 March 2009 - 01:14 PM

Was This Post Helpful? 1
  • +
  • -

#6 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: How to draw flowchart for SWITCH?

Posted 28 March 2009 - 01:11 PM

Google is your friend, don't shun your friends. They love you...

Flowchart of a Statement - Switch Statement example

.. And if you don't like how many boxes there are, revise your logic. If you have too many switch cases there is probably a more efficient way. But from what you show, that is perfectly fine for this diagram shown in the link above.

;)

This post has been edited by Martyr2: 28 March 2009 - 01:13 PM

Was This Post Helpful? 1

#7 mixch_s  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 8
  • Joined: 26-March 09

Re: How to draw flowchart for SWITCH?

Posted 28 March 2009 - 01:27 PM

As what martyr2 shown to me
i have to draw 10 condition

but the problem is i got 3 switch in one programme as im doing roman numerals which intake a year and compute it to roman numerals

My switch is divided to 3 categorize, hundreds, tens and ones
So one switch got 10 diamonds
and there is three switchs which i need to draw 30 diamonds....

Arghhh one A4 paper size is not enough for me to draw...

Help me!!! :crazy:
Was This Post Helpful? 0
  • +
  • -

#8 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: How to draw flowchart for SWITCH?

Posted 28 March 2009 - 01:40 PM

30 Diamonds? There are only 7 Numerals you have to worry about... I, V, X, L, C, D, and M is 1000.

You can accomplish this using a very straight forward function. I don't see needing 3 switch statements for this.

But anyways... whatever works for you. You asked about a flow chart for a switch, that is what I showed you. :)
Was This Post Helpful? 0
  • +
  • -

#9 mixch_s  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 8
  • Joined: 26-March 09

Re: How to draw flowchart for SWITCH?

Posted 28 March 2009 - 02:14 PM

The question require the user input the year between 1 till 9999
so i have to check condition whether the input year is between
100 to 999
11 to 99
1 to 10

each of them got a switch...
Am i doing the wrong thing???
Was This Post Helpful? 0
  • +
  • -

#10 mixch_s  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 8
  • Joined: 26-March 09

Re: How to draw flowchart for SWITCH?

Posted 28 March 2009 - 02:59 PM

I get it..Alternative way without using switch..
Thanks for the help
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1