//* Demonstrates: how NOT TO USE if-else *

#include <stdio.h> int main() { double ph; printf("Welcome to a simple chemical expert system:\n"); printf("Please specify the PH for the substance.\n"); printf("ph="); scanf("%lf", &ph); if (ph>=0.0&&ph<3.5) printf("It is very acidic!\a\n"); if (ph>=3.5&&ph<6.9) printf("It is acidic.\n"); if (ph>=6.9&&ph<7.1) printf("It is about neutral.\n"); if (ph>=7.1&&ph<9.9) printf("It is basic.\n"); if (ph>=9.5&&ph<=14) printf("It is very basic!\a.\n"); // - Does not handle cases <0 and >14 // - Compares numbers many times, much more than it is necessary // + it is easier to follow for a human (only a little) return(0); }