Solution for Exercise 13-5
ex1305
#include <stdio.h> #include <ctype.h> int main() { char answer; printf("Would you like to blow up the moon? "); scanf("%c",&answer); answer = toupper(answer); if(answer=='Y') puts("BOOM!"); else if(answer=='N') puts("The moon is safe"); else puts("Indecision can be fatal!"); return(0); }
Notes
* The obvious solution is to construct an if-else if-else structure. Even so, you'd get points if you constructed a switch-case structure instead. Either method would solve the problem.
* If you'd like the practice, construct a switch-case solution.
Copyright © 1997-2024 by QPBC.
All rights reserved