Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variables neutral, base, and acid: a. 0,0,1 if pH is less than 7 b. 0,1,0 if pH is greater than 7 c. 1,0,0 if pH is equal to 7

Respuesta :

ijeggs

Answer:

int main()

{

   double pH;

   int neutral;

   int base;

   int acid;

   cout<<"Enter a pH Value";

   cin>> pH;

   if(pH<7.0){

       neutral =0;

       base=0;

       acid= 1;

   }

   else if (pH=7.0){

       neutral =1;

       base=0;

       acid= 0;

   }

   else{

       neutral =0;

       base=1;

       acid= 0;

   }

   cout <<"The neutral, Base and Acid Values are: "<<neutral<<","<<base<<","<<acid<<" Respectively"<<endl;

   return 0;

}

Explanation:

Using multiple if/elseif/else statement the following problem is solved with C++