主页
C 语言
C 类型转换
demo_type_conversion_reallife
运行 ❯
×
更改方向
保存代码
更改主题
#include
int main() { // Set the maximum possible score to 500 int maxScore = 500; // The actual score of the user int userScore = 423; // Calculate the percantage of the user's score in relation to the maximum available score float percentage = (float) userScore / maxScore * 100.0; // Print the percentage printf("User's percentage is %.2f", percentage); return 0; }
User's percentage is 84.60