I dont know whats wrong with my code..
when i entered the value,there was nothing appeared on my screen..

I've tried put the single quote like this one :
case '1' :
cout<<Very Acidic;
break;

..but it was only works for the acidic value..When i entered the value more than 7,it will display the "very acidic" statement and not the value that it supposed to display..

Thank you :)

#include <iostream>
using namespace std;

int main () {
  char ph;
 
  cout<<"Enter the ph value";
  cin>>ph;
  cout<<endl;

  switch (ph) {
    
      case 1 :
         cout<<"Very Acidic";
         break;

      case 2 :
         cout<<"Acidic";
         break;

       case 3 :
          cout<<"Acidic";
          break;

       case 4 :
          cout<<"Acidic";
          break;

       case 5 :
          cout<<"Acidic";
          break;

        case 6 :
          cout<<"Acidic";
          break;

        case 7 :
          cout<<"neutral";
          break;

        case 8:
          cout<<"Alkaline";
          break;

        case 9:
         cout<<"Alkaline";
          break;

        case 10:
          cout<<"Alkaline";
          break;

        case 11:
          cout<<"Alkaline";
          break;

        case 12:
          cout<<"Alkaline";
          break;

        case 14:
          cout<<"Alkaline";
          break;

        default : cout<<"wrong input ";

cin.get()
}

Just change ph to an int (it doesn't work because 10-14 aren't chars, they are strings)

And you're missing a semicolon after cin.get() and you need to close your switch statement with a brace

Edited 7 Years Ago by jonsca: n/a

This article has been dead for over six months. Start a new discussion instead.