mercredi 7 février 2018

Change from if - else statement to switch - case statement in c programming

 while (ch = getchar ( ) != '\n')
        {
        if (ch=='a')
            ++count_a;
        else if (ch=='b')
            ++count_b;
        else if (ch=='c')
            ++count_c;
        else
            ++count_other;
        }


  • This is the original question that given by my teacher (I think some where wrong)
  • If there are some where wrong pls correct it
  • convert into switch-case statement thank you

Aucun commentaire:

Enregistrer un commentaire