title: I want to use one switch case instead of two switch cases
body: <pre><code>int SumOfCards(char str[], int n)
  {
     if(n==0)
     return -1;
     int sum1,sum2;
     char temp[2];
     if(str[1]==' ')
     temp[0]= str[2];
     else if(str[2]==' ')
     temp[0] = str[3];
  
  switch(str[0])
  {
      case '2' : sum1 = 2;
      break;
      case '3' : sum1 = 3;
      break;
      case '4' : sum1 = 4;
      break;
      case '5' : sum1 = 5;
      break;
      case '6' : sum1 = 6;
      break;
      case '7' : sum1 = 7;
      break;
      case '8' : sum1 = 8;
      break;
      case '9' : sum1 = 9;
      break;
      case '1' : sum1 = 10;
      break;
      case 'K' : sum1 = 10;
      break;
      case 'J' : sum1 = 10;
      break;
      case 'Q' : sum1 = 10;
      break;
      case 'A' : sum1 = 11;
      break;
      default : sum1 = 0;
      break;
  
  }
   switch(temp[0])
  {
  
      case '2' : sum2 = 2;
      break;
      case '3' : sum2 = 3;
      break;
      case '4' : sum2 = 4;
      break;
      case '5' : sum2 = 5;
      break;
      case '6' : sum2 = 6;
      break;
      case '7' : sum2 = 7;
      break;
      case '8' : sum2 = 8;
      break;
      case '9' : sum2 = 9;
      break;
      case '1' : sum2 = 10;
      break;
      case 'K' : sum2 = 10;
      break;
      case 'J' : sum2 = 10;
      break;
      case 'Q' : sum2 = 10;
      break;
      case 'A' : sum2 = 11;
      break;
      default : sum2 = 0;
      break;
  
  }
     if(str[0]== 'A' &amp;&amp; temp[0]== 'A')
     {sum1 = 1;
     sum2 = 1;
     }
     int sum = sum1 + sum2;
     return sum;
  
  }
  </code></pre>
  
  <p>This is a program for sum of two cards value from deck of card. Cards consist value from 2,3,...10 and J, A, Q and K. str[0] consist the value of first card and temp[0] consist the value of second card I want to use one switch case instead of two switch case because cases for str[0] and temp[0] are same. So, can i use only one switch case instead of two switch case. How, can i do it?</p>