How to calculate X is what % of Y in C++

1 Answer

0 votes
#include <iostream>

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

    double percent = (x / y) * 100.0;
    
    std::cout << x << " is " << percent << "% of " << y << std::endl;
}



/*
run:

47 is 21.3636% of 220

*/

 



answered May 29 by avibootz
...