Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a Search or enter website name NAME pow-raises a number to a power and displays

ID: 3812724 • Letter: A

Question

a Search or enter website name NAME pow-raises a number to a power and displays it on the screen. SYNOPSIS pow BAS EXPONENT E DESCRIPTION Accepts two values, a base value and an exponent, when run from the command-line. pow then raises the base to the exponent and displays to the screen the result. EXAMPLES displays synopsis message pow pow 3 2 displays 9 pow 1.5 2 displays 2.25 pow 2 -2 displays .25 displays synopsis message pow NOTES Displays the synopsis message if an incorrect number of command line arguments are supplied. Does not use any C++ specific code Does not prompt the user in any way. Does not perform input validation. Does not use scanf uses command-line arguments to get input. To compile the code gcc pow.c-o pow or gcc-lm pow.c-o pow HINTS Use c-string C functions from the C library. If there isn't an explicit requirement, you don't have to do it. 10-POINT SAMPLE RUN [stalica trig CC lm pow.c opow [stalica trig pow 3 2 9.000000 [stalica trig pow 1.5 2 2.250000

Explanation / Answer

include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        printf("USAGE: pow BASE EXP ");
        return 1;
    }
    double base = atof(argv[1]);
    double exp = atoi(argv[2]);
    printf("%.6f ", pow(base, exp));
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote