/** * Get a decibel level (as a double) from the command line and using the belo
ID: 3750907 • Letter: #
Question
/**
* Get a decibel level (as a double) from the command line and using the below
* list of dB levels print a description of what that dB represents, i.e.
* dB < 10 is "Threshold of Hearing", dB < 98 is "Large Orchestra" and anything
* from 160 and above is "Instant Perforation of Eardrum". If no command line
* argument is provided print the usage message: "Usage: h2 dblevel" to the
* console and quit. Use the atof(3) function to convert the command line
* parameter to a double.
*
* Threshold of Hearing 0 dB
* Rustling Leaves 10 dB
* Whisper 20 dB
* Normal Conversation 60 dB
* Busy Street Traffic 70 dB
* Vacuum Cleaner 80 dB
* Large Orchestra 98 dB
* Walkman at Maximum Level 100 dB
* Front Rows of Rock Concert 110 dB
* Threshold of Pain 130 dB
* Military Jet Takeoff 140 dB
* Instant Perforation of Eardrum 160 dB
*/
int main(int argc, char *argv[])
{
return 0;
}
Explanation / Answer
#include #include /** * Get a decibel level (as a double) from the command line and using the below * list of dB levels print a description of what that dB represents, i.e. * dB < 10 is "Threshold of Hearing", dB < 98 is "Large Orchestra" and anything * from 160 and above is "Instant Perforation of Eardrum". If no command line * argument is provided print the usage message: "Usage: h2 dblevel" to the * console and quit. Use the atof(3) function to convert the command line * parameter to a double. * * Threshold of Hearing 0 dB * Rustling Leaves 10 dB * Whisper 20 dB * Normal Conversation 60 dB * Busy Street Traffic 70 dB * Vacuum Cleaner 80 dB * Large Orchestra 98 dB * Walkman at Maximum Level 100 dB * Front Rows of Rock Concert 110 dB * Threshold of Pain 130 dB * Military Jet Takeoff 140 dB * Instant Perforation of Eardrum 160 dB */ int main(int argc, char *argv[]) { if(argc >= 2) { double db = atof(argv[1]); if(dbRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.