How to write a C Program to Gets loudness level from user; chooses a response And prints it using logical and operative statements in C Programming Language ?
Solution:
/* Gets loudness level from user; choses a response * And prints it using logical and operative statements. */ #include <stdio.h> int main(){ /* It's an int because it worked out weird with decimals */ int Loudness, GoAgain; BEGINAGAIN: printf("How loud (in decibel levels) are you? No decimals please.\n"); scanf("%d", &Loudness); /* Determines the response: */ if (Loudness <= 50) /* reverts to this if more than 21 digits are entered */ printf("Speak up!! You're too quiet\n\n"); else if (Loudness > 50 && Loudness <= 70) /* 51-70 */ printf("That's better, now I can hear you\n\n"); else if (Loudness > 70 && Loudness <= 90) /* 71-90 */ printf("Too loud, you are getting annoying\n\n"); else if (Loudness > 90 && Loudness <= 110) /* 91-110 */ printf("Quiet, you ARE annoying!\n\n"); else if (Loudness > 110) /* Note - reverts to what I can only assumed to be 0 when over 21 digits */ printf("Ahhhh, now you sound like Mr. Adamakos!!!\n\n"); /* Should never be displayed */ else printf("Error\n\n"); /* Debugging tool: Lets the code repeat over and over again. * Commented out because it causes weird reactions with decimals */ /* printf("Go again? y = 1, n = 0\n"); scanf("%d", &GoAgain); if(GoAgain == 1) { printf("\n\n"); goto BEGINAGAIN; } */ return 0; }