How to calculate the percentage of a percentage in C

1 Answer

0 votes
#include <stdio.h>

double percent_of_percent(double value, double percent) {
    return value * (percent / 100.0);
}

int main(void) {
    double a = 58;
    double b = 17;

    double result = percent_of_percent(a, b);

    printf("%.2f\n", result);  
    
    return 0;
}



/*
run:

9.86

*/

 



answered Mar 17 by avibootz
edited Mar 17 by avibootz
...