Return to Class Main Page
Return to Class Main Page
Example: Suppose you need to add random amounts to a total based on a value. Here are three examples that do that:
if (1 == i) { total = total + 17; } elseif (2 == i) { total = total + 29; } elseif (3 == i) { total = total + 99; }
switch (i) { // switch Case 1: total = total + 17; break; Case 2: total = total + 29; break; Case 3: total = total + 99; break; } // switch
int ary[4] {0, 17, 29, 99}; total = total + ary[i];
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
(undirected) 1 to 2 = 7 1 to 6 = 14 2 to 3 = 10 2 to 4 = 15 3 to 4 = 11 3 to 6 = 2 4 to 5 = 6 5 to 6 = 9
(directed) 1 to 2 = 8 1 to 4 = 1 2 to 3 = 1 3 to 1 = 4 4 to 2 = 2 4 to 3 = 9
Return to Class Main Page
Return to Class Main Page
Return to Class Main Page
The statements and opinions included in these pages are those of only. Any statements and
opinions included in these pages are not those of Louisiana
State University or the LSU Board of Supervisors.
© 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015