How to calculate X is what % of Y in C

1 Answer

0 votes
#include <stdio.h>

int main() {
    double x = 47, y = 220;

    double percent = (x / y) * 100.0;

    printf("%.0f is %.4f%% of %.0f\n", x, percent, y);

    return 0;
}


/*
run:

47 is 21.3636% of 220

*/

 



answered May 29 by avibootz
...